<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>pdfToText: C:/Users/Jonas/Documents/Visual Studio 2008/Projects/pdfToText/pdfToText/zlib.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="logo2.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">pdfToText
   &#160;<span id="projectnumber">2.0</span>
   </div>
   <div id="projectbrief">PDF to text conversion tool</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">C:/Users/Jonas/Documents/Visual Studio 2008/Projects/pdfToText/pdfToText/zlib.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* zlib.h -- interface of the &#39;zlib&#39; general purpose compression library</span>
<a name="l00002"></a>00002 <span class="comment">  version 1.2.3, July 18th, 2005</span>
<a name="l00003"></a>00003 <span class="comment"></span>
<a name="l00004"></a>00004 <span class="comment">  Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler</span>
<a name="l00005"></a>00005 <span class="comment"></span>
<a name="l00006"></a>00006 <span class="comment">  This software is provided &#39;as-is&#39;, without any express or implied</span>
<a name="l00007"></a>00007 <span class="comment">  warranty.  In no event will the authors be held liable for any damages</span>
<a name="l00008"></a>00008 <span class="comment">  arising from the use of this software.</span>
<a name="l00009"></a>00009 <span class="comment"></span>
<a name="l00010"></a>00010 <span class="comment">  Permission is granted to anyone to use this software for any purpose,</span>
<a name="l00011"></a>00011 <span class="comment">  including commercial applications, and to alter it and redistribute it</span>
<a name="l00012"></a>00012 <span class="comment">  freely, subject to the following restrictions:</span>
<a name="l00013"></a>00013 <span class="comment"></span>
<a name="l00014"></a>00014 <span class="comment">  1. The origin of this software must not be misrepresented; you must not</span>
<a name="l00015"></a>00015 <span class="comment">     claim that you wrote the original software. If you use this software</span>
<a name="l00016"></a>00016 <span class="comment">     in a product, an acknowledgment in the product documentation would be</span>
<a name="l00017"></a>00017 <span class="comment">     appreciated but is not required.</span>
<a name="l00018"></a>00018 <span class="comment">  2. Altered source versions must be plainly marked as such, and must not be</span>
<a name="l00019"></a>00019 <span class="comment">     misrepresented as being the original software.</span>
<a name="l00020"></a>00020 <span class="comment">  3. This notice may not be removed or altered from any source distribution.</span>
<a name="l00021"></a>00021 <span class="comment"></span>
<a name="l00022"></a>00022 <span class="comment">  Jean-loup Gailly        Mark Adler</span>
<a name="l00023"></a>00023 <span class="comment">  jloup@gzip.org          madler@alumni.caltech.edu</span>
<a name="l00024"></a>00024 <span class="comment"></span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">  The data format used by the zlib library is described by RFCs (Request for</span>
<a name="l00027"></a>00027 <span class="comment">  Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt</span>
<a name="l00028"></a>00028 <span class="comment">  (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).</span>
<a name="l00029"></a>00029 <span class="comment">*/</span>
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="preprocessor">#ifndef ZLIB_H</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor">#define ZLIB_H</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &quot;zconf.h&quot;</span>
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {
<a name="l00038"></a>00038 <span class="preprocessor">#endif</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span>
<a name="l00040"></a>00040 <span class="preprocessor">#define ZLIB_VERSION &quot;1.2.3&quot;</span>
<a name="l00041"></a>00041 <span class="preprocessor"></span><span class="preprocessor">#define ZLIB_VERNUM 0x1230</span>
<a name="l00042"></a>00042 <span class="preprocessor"></span>
<a name="l00043"></a>00043 <span class="comment">/*</span>
<a name="l00044"></a>00044 <span class="comment">     The &#39;zlib&#39; compression library provides in-memory compression and</span>
<a name="l00045"></a>00045 <span class="comment">  decompression functions, including integrity checks of the uncompressed</span>
<a name="l00046"></a>00046 <span class="comment">  data.  This version of the library supports only one compression method</span>
<a name="l00047"></a>00047 <span class="comment">  (deflation) but other algorithms will be added later and will have the same</span>
<a name="l00048"></a>00048 <span class="comment">  stream interface.</span>
<a name="l00049"></a>00049 <span class="comment"></span>
<a name="l00050"></a>00050 <span class="comment">     Compression can be done in a single step if the buffers are large</span>
<a name="l00051"></a>00051 <span class="comment">  enough (for example if an input file is mmap&#39;ed), or can be done by</span>
<a name="l00052"></a>00052 <span class="comment">  repeated calls of the compression function.  In the latter case, the</span>
<a name="l00053"></a>00053 <span class="comment">  application must provide more input and/or consume the output</span>
<a name="l00054"></a>00054 <span class="comment">  (providing more output space) before each call.</span>
<a name="l00055"></a>00055 <span class="comment"></span>
<a name="l00056"></a>00056 <span class="comment">     The compressed data format used by default by the in-memory functions is</span>
<a name="l00057"></a>00057 <span class="comment">  the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped</span>
<a name="l00058"></a>00058 <span class="comment">  around a deflate stream, which is itself documented in RFC 1951.</span>
<a name="l00059"></a>00059 <span class="comment"></span>
<a name="l00060"></a>00060 <span class="comment">     The library also supports reading and writing files in gzip (.gz) format</span>
<a name="l00061"></a>00061 <span class="comment">  with an interface similar to that of stdio using the functions that start</span>
<a name="l00062"></a>00062 <span class="comment">  with &quot;gz&quot;.  The gzip format is different from the zlib format.  gzip is a</span>
<a name="l00063"></a>00063 <span class="comment">  gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.</span>
<a name="l00064"></a>00064 <span class="comment"></span>
<a name="l00065"></a>00065 <span class="comment">     This library can optionally read and write gzip streams in memory as well.</span>
<a name="l00066"></a>00066 <span class="comment"></span>
<a name="l00067"></a>00067 <span class="comment">     The zlib format was designed to be compact and fast for use in memory</span>
<a name="l00068"></a>00068 <span class="comment">  and on communications channels.  The gzip format was designed for single-</span>
<a name="l00069"></a>00069 <span class="comment">  file compression on file systems, has a larger header than zlib to maintain</span>
<a name="l00070"></a>00070 <span class="comment">  directory information, and uses a different, slower check method than zlib.</span>
<a name="l00071"></a>00071 <span class="comment"></span>
<a name="l00072"></a>00072 <span class="comment">     The library does not install any signal handler. The decoder checks</span>
<a name="l00073"></a>00073 <span class="comment">  the consistency of the compressed data, so the library should never</span>
<a name="l00074"></a>00074 <span class="comment">  crash even in case of corrupted input.</span>
<a name="l00075"></a>00075 <span class="comment">*/</span>
<a name="l00076"></a>00076 
<a name="l00077"></a>00077 <span class="keyword">typedef</span> voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
<a name="l00078"></a>00078 typedef <span class="keywordtype">void</span>   (*free_func)  OF((voidpf opaque, voidpf address));
<a name="l00079"></a>00079 
<a name="l00080"></a>00080 struct <a class="code" href="structinternal__state.html">internal_state</a>;
<a name="l00081"></a>00081 
<a name="l00082"></a><a class="code" href="structz__stream__s.html">00082</a> typedef struct <a class="code" href="structz__stream__s.html">z_stream_s</a> {
<a name="l00083"></a>00083     Bytef    *next_in;  <span class="comment">/* next input byte */</span>
<a name="l00084"></a>00084     uInt     avail_in;  <span class="comment">/* number of bytes available at next_in */</span>
<a name="l00085"></a>00085     uLong    total_in;  <span class="comment">/* total nb of input bytes read so far */</span>
<a name="l00086"></a>00086 
<a name="l00087"></a>00087     Bytef    *next_out; <span class="comment">/* next output byte should be put there */</span>
<a name="l00088"></a>00088     uInt     avail_out; <span class="comment">/* remaining free space at next_out */</span>
<a name="l00089"></a>00089     uLong    total_out; <span class="comment">/* total nb of bytes output so far */</span>
<a name="l00090"></a>00090 
<a name="l00091"></a>00091     <span class="keywordtype">char</span>     *msg;      <span class="comment">/* last error message, NULL if no error */</span>
<a name="l00092"></a>00092     <span class="keyword">struct </span>internal_state FAR *state; <span class="comment">/* not visible by applications */</span>
<a name="l00093"></a>00093 
<a name="l00094"></a>00094     alloc_func zalloc;  <span class="comment">/* used to allocate the internal state */</span>
<a name="l00095"></a>00095     free_func  zfree;   <span class="comment">/* used to free the internal state */</span>
<a name="l00096"></a>00096     voidpf     opaque;  <span class="comment">/* private data object passed to zalloc and zfree */</span>
<a name="l00097"></a>00097 
<a name="l00098"></a>00098     <span class="keywordtype">int</span>     data_type;  <span class="comment">/* best guess about the data type: binary or text */</span>
<a name="l00099"></a>00099     uLong   adler;      <span class="comment">/* adler32 value of the uncompressed data */</span>
<a name="l00100"></a>00100     uLong   reserved;   <span class="comment">/* reserved for future use */</span>
<a name="l00101"></a>00101 } <a class="code" href="structz__stream__s.html">z_stream</a>;
<a name="l00102"></a>00102 
<a name="l00103"></a>00103 <span class="keyword">typedef</span> <a class="code" href="structz__stream__s.html">z_stream</a> FAR *z_streamp;
<a name="l00104"></a>00104 
<a name="l00105"></a>00105 <span class="comment">/*</span>
<a name="l00106"></a>00106 <span class="comment">     gzip header information passed to and from zlib routines.  See RFC 1952</span>
<a name="l00107"></a>00107 <span class="comment">  for more details on the meanings of these fields.</span>
<a name="l00108"></a>00108 <span class="comment">*/</span>
<a name="l00109"></a><a class="code" href="structgz__header__s.html">00109</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structgz__header__s.html">gz_header_s</a> {
<a name="l00110"></a>00110     <span class="keywordtype">int</span>     text;       <span class="comment">/* true if compressed data believed to be text */</span>
<a name="l00111"></a>00111     uLong   time;       <span class="comment">/* modification time */</span>
<a name="l00112"></a>00112     <span class="keywordtype">int</span>     xflags;     <span class="comment">/* extra flags (not used when writing a gzip file) */</span>
<a name="l00113"></a>00113     <span class="keywordtype">int</span>     os;         <span class="comment">/* operating system */</span>
<a name="l00114"></a>00114     Bytef   *extra;     <span class="comment">/* pointer to extra field or Z_NULL if none */</span>
<a name="l00115"></a>00115     uInt    extra_len;  <span class="comment">/* extra field length (valid if extra != Z_NULL) */</span>
<a name="l00116"></a>00116     uInt    extra_max;  <span class="comment">/* space at extra (only when reading header) */</span>
<a name="l00117"></a>00117     Bytef   *name;      <span class="comment">/* pointer to zero-terminated file name or Z_NULL */</span>
<a name="l00118"></a>00118     uInt    name_max;   <span class="comment">/* space at name (only when reading header) */</span>
<a name="l00119"></a>00119     Bytef   *comment;   <span class="comment">/* pointer to zero-terminated comment or Z_NULL */</span>
<a name="l00120"></a>00120     uInt    comm_max;   <span class="comment">/* space at comment (only when reading header) */</span>
<a name="l00121"></a>00121     <span class="keywordtype">int</span>     hcrc;       <span class="comment">/* true if there was or will be a header crc */</span>
<a name="l00122"></a>00122     <span class="keywordtype">int</span>     done;       <span class="comment">/* true when done reading gzip header (not used</span>
<a name="l00123"></a>00123 <span class="comment">                           when writing a gzip file) */</span>
<a name="l00124"></a>00124 } <a class="code" href="structgz__header__s.html">gz_header</a>;
<a name="l00125"></a>00125 
<a name="l00126"></a>00126 <span class="keyword">typedef</span> <a class="code" href="structgz__header__s.html">gz_header</a> FAR *gz_headerp;
<a name="l00127"></a>00127 
<a name="l00128"></a>00128 <span class="comment">/*</span>
<a name="l00129"></a>00129 <span class="comment">   The application must update next_in and avail_in when avail_in has</span>
<a name="l00130"></a>00130 <span class="comment">   dropped to zero. It must update next_out and avail_out when avail_out</span>
<a name="l00131"></a>00131 <span class="comment">   has dropped to zero. The application must initialize zalloc, zfree and</span>
<a name="l00132"></a>00132 <span class="comment">   opaque before calling the init function. All other fields are set by the</span>
<a name="l00133"></a>00133 <span class="comment">   compression library and must not be updated by the application.</span>
<a name="l00134"></a>00134 <span class="comment"></span>
<a name="l00135"></a>00135 <span class="comment">   The opaque value provided by the application will be passed as the first</span>
<a name="l00136"></a>00136 <span class="comment">   parameter for calls of zalloc and zfree. This can be useful for custom</span>
<a name="l00137"></a>00137 <span class="comment">   memory management. The compression library attaches no meaning to the</span>
<a name="l00138"></a>00138 <span class="comment">   opaque value.</span>
<a name="l00139"></a>00139 <span class="comment"></span>
<a name="l00140"></a>00140 <span class="comment">   zalloc must return Z_NULL if there is not enough memory for the object.</span>
<a name="l00141"></a>00141 <span class="comment">   If zlib is used in a multi-threaded application, zalloc and zfree must be</span>
<a name="l00142"></a>00142 <span class="comment">   thread safe.</span>
<a name="l00143"></a>00143 <span class="comment"></span>
<a name="l00144"></a>00144 <span class="comment">   On 16-bit systems, the functions zalloc and zfree must be able to allocate</span>
<a name="l00145"></a>00145 <span class="comment">   exactly 65536 bytes, but will not be required to allocate more than this</span>
<a name="l00146"></a>00146 <span class="comment">   if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,</span>
<a name="l00147"></a>00147 <span class="comment">   pointers returned by zalloc for objects of exactly 65536 bytes *must*</span>
<a name="l00148"></a>00148 <span class="comment">   have their offset normalized to zero. The default allocation function</span>
<a name="l00149"></a>00149 <span class="comment">   provided by this library ensures this (see zutil.c). To reduce memory</span>
<a name="l00150"></a>00150 <span class="comment">   requirements and avoid any allocation of 64K objects, at the expense of</span>
<a name="l00151"></a>00151 <span class="comment">   compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).</span>
<a name="l00152"></a>00152 <span class="comment"></span>
<a name="l00153"></a>00153 <span class="comment">   The fields total_in and total_out can be used for statistics or</span>
<a name="l00154"></a>00154 <span class="comment">   progress reports. After compression, total_in holds the total size of</span>
<a name="l00155"></a>00155 <span class="comment">   the uncompressed data and may be saved for use in the decompressor</span>
<a name="l00156"></a>00156 <span class="comment">   (particularly if the decompressor wants to decompress everything in</span>
<a name="l00157"></a>00157 <span class="comment">   a single step).</span>
<a name="l00158"></a>00158 <span class="comment">*/</span>
<a name="l00159"></a>00159 
<a name="l00160"></a>00160                         <span class="comment">/* constants */</span>
<a name="l00161"></a>00161 
<a name="l00162"></a>00162 <span class="preprocessor">#define Z_NO_FLUSH      0</span>
<a name="l00163"></a>00163 <span class="preprocessor"></span><span class="preprocessor">#define Z_PARTIAL_FLUSH 1 </span><span class="comment">/* will be removed, use Z_SYNC_FLUSH instead */</span>
<a name="l00164"></a>00164 <span class="preprocessor">#define Z_SYNC_FLUSH    2</span>
<a name="l00165"></a>00165 <span class="preprocessor"></span><span class="preprocessor">#define Z_FULL_FLUSH    3</span>
<a name="l00166"></a>00166 <span class="preprocessor"></span><span class="preprocessor">#define Z_FINISH        4</span>
<a name="l00167"></a>00167 <span class="preprocessor"></span><span class="preprocessor">#define Z_BLOCK         5</span>
<a name="l00168"></a>00168 <span class="preprocessor"></span><span class="comment">/* Allowed flush values; see deflate() and inflate() below for details */</span>
<a name="l00169"></a>00169 
<a name="l00170"></a>00170 <span class="preprocessor">#define Z_OK            0</span>
<a name="l00171"></a>00171 <span class="preprocessor"></span><span class="preprocessor">#define Z_STREAM_END    1</span>
<a name="l00172"></a>00172 <span class="preprocessor"></span><span class="preprocessor">#define Z_NEED_DICT     2</span>
<a name="l00173"></a>00173 <span class="preprocessor"></span><span class="preprocessor">#define Z_ERRNO        (-1)</span>
<a name="l00174"></a>00174 <span class="preprocessor"></span><span class="preprocessor">#define Z_STREAM_ERROR (-2)</span>
<a name="l00175"></a>00175 <span class="preprocessor"></span><span class="preprocessor">#define Z_DATA_ERROR   (-3)</span>
<a name="l00176"></a>00176 <span class="preprocessor"></span><span class="preprocessor">#define Z_MEM_ERROR    (-4)</span>
<a name="l00177"></a>00177 <span class="preprocessor"></span><span class="preprocessor">#define Z_BUF_ERROR    (-5)</span>
<a name="l00178"></a>00178 <span class="preprocessor"></span><span class="preprocessor">#define Z_VERSION_ERROR (-6)</span>
<a name="l00179"></a>00179 <span class="preprocessor"></span><span class="comment">/* Return codes for the compression/decompression functions. Negative</span>
<a name="l00180"></a>00180 <span class="comment"> * values are errors, positive values are used for special but normal events.</span>
<a name="l00181"></a>00181 <span class="comment"> */</span>
<a name="l00182"></a>00182 
<a name="l00183"></a>00183 <span class="preprocessor">#define Z_NO_COMPRESSION         0</span>
<a name="l00184"></a>00184 <span class="preprocessor"></span><span class="preprocessor">#define Z_BEST_SPEED             1</span>
<a name="l00185"></a>00185 <span class="preprocessor"></span><span class="preprocessor">#define Z_BEST_COMPRESSION       9</span>
<a name="l00186"></a>00186 <span class="preprocessor"></span><span class="preprocessor">#define Z_DEFAULT_COMPRESSION  (-1)</span>
<a name="l00187"></a>00187 <span class="preprocessor"></span><span class="comment">/* compression levels */</span>
<a name="l00188"></a>00188 
<a name="l00189"></a>00189 <span class="preprocessor">#define Z_FILTERED            1</span>
<a name="l00190"></a>00190 <span class="preprocessor"></span><span class="preprocessor">#define Z_HUFFMAN_ONLY        2</span>
<a name="l00191"></a>00191 <span class="preprocessor"></span><span class="preprocessor">#define Z_RLE                 3</span>
<a name="l00192"></a>00192 <span class="preprocessor"></span><span class="preprocessor">#define Z_FIXED               4</span>
<a name="l00193"></a>00193 <span class="preprocessor"></span><span class="preprocessor">#define Z_DEFAULT_STRATEGY    0</span>
<a name="l00194"></a>00194 <span class="preprocessor"></span><span class="comment">/* compression strategy; see deflateInit2() below for details */</span>
<a name="l00195"></a>00195 
<a name="l00196"></a>00196 <span class="preprocessor">#define Z_BINARY   0</span>
<a name="l00197"></a>00197 <span class="preprocessor"></span><span class="preprocessor">#define Z_TEXT     1</span>
<a name="l00198"></a>00198 <span class="preprocessor"></span><span class="preprocessor">#define Z_ASCII    Z_TEXT   </span><span class="comment">/* for compatibility with 1.2.2 and earlier */</span>
<a name="l00199"></a>00199 <span class="preprocessor">#define Z_UNKNOWN  2</span>
<a name="l00200"></a>00200 <span class="preprocessor"></span><span class="comment">/* Possible values of the data_type field (though see inflate()) */</span>
<a name="l00201"></a>00201 
<a name="l00202"></a>00202 <span class="preprocessor">#define Z_DEFLATED   8</span>
<a name="l00203"></a>00203 <span class="preprocessor"></span><span class="comment">/* The deflate compression method (the only one supported in this version) */</span>
<a name="l00204"></a>00204 
<a name="l00205"></a>00205 <span class="preprocessor">#define Z_NULL  0  </span><span class="comment">/* for initializing zalloc, zfree, opaque */</span>
<a name="l00206"></a>00206 
<a name="l00207"></a>00207 <span class="preprocessor">#define zlib_version zlibVersion()</span>
<a name="l00208"></a>00208 <span class="preprocessor"></span><span class="comment">/* for compatibility with versions &lt; 1.0.2 */</span>
<a name="l00209"></a>00209 
<a name="l00210"></a>00210                         <span class="comment">/* basic functions */</span>
<a name="l00211"></a>00211 
<a name="l00212"></a>00212 ZEXTERN <span class="keyword">const</span> <span class="keywordtype">char</span> * ZEXPORT zlibVersion OF((<span class="keywordtype">void</span>));
<a name="l00213"></a>00213 <span class="comment">/* The application can compare zlibVersion and ZLIB_VERSION for consistency.</span>
<a name="l00214"></a>00214 <span class="comment">   If the first character differs, the library code actually used is</span>
<a name="l00215"></a>00215 <span class="comment">   not compatible with the zlib.h header file used by the application.</span>
<a name="l00216"></a>00216 <span class="comment">   This check is automatically made by deflateInit and inflateInit.</span>
<a name="l00217"></a>00217 <span class="comment"> */</span>
<a name="l00218"></a>00218 
<a name="l00219"></a>00219 <span class="comment">/*</span>
<a name="l00220"></a>00220 <span class="comment">ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));</span>
<a name="l00221"></a>00221 <span class="comment"></span>
<a name="l00222"></a>00222 <span class="comment">     Initializes the internal stream state for compression. The fields</span>
<a name="l00223"></a>00223 <span class="comment">   zalloc, zfree and opaque must be initialized before by the caller.</span>
<a name="l00224"></a>00224 <span class="comment">   If zalloc and zfree are set to Z_NULL, deflateInit updates them to</span>
<a name="l00225"></a>00225 <span class="comment">   use default allocation functions.</span>
<a name="l00226"></a>00226 <span class="comment"></span>
<a name="l00227"></a>00227 <span class="comment">     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:</span>
<a name="l00228"></a>00228 <span class="comment">   1 gives best speed, 9 gives best compression, 0 gives no compression at</span>
<a name="l00229"></a>00229 <span class="comment">   all (the input data is simply copied a block at a time).</span>
<a name="l00230"></a>00230 <span class="comment">   Z_DEFAULT_COMPRESSION requests a default compromise between speed and</span>
<a name="l00231"></a>00231 <span class="comment">   compression (currently equivalent to level 6).</span>
<a name="l00232"></a>00232 <span class="comment"></span>
<a name="l00233"></a>00233 <span class="comment">     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not</span>
<a name="l00234"></a>00234 <span class="comment">   enough memory, Z_STREAM_ERROR if level is not a valid compression level,</span>
<a name="l00235"></a>00235 <span class="comment">   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible</span>
<a name="l00236"></a>00236 <span class="comment">   with the version assumed by the caller (ZLIB_VERSION).</span>
<a name="l00237"></a>00237 <span class="comment">   msg is set to null if there is no error message.  deflateInit does not</span>
<a name="l00238"></a>00238 <span class="comment">   perform any compression: this will be done by deflate().</span>
<a name="l00239"></a>00239 <span class="comment">*/</span>
<a name="l00240"></a>00240 
<a name="l00241"></a>00241 
<a name="l00242"></a>00242 ZEXTERN <span class="keywordtype">int</span> ZEXPORT deflate OF((z_streamp strm, <span class="keywordtype">int</span> flush));
<a name="l00243"></a>00243 <span class="comment">/*</span>
<a name="l00244"></a>00244 <span class="comment">    deflate compresses as much data as possible, and stops when the input</span>
<a name="l00245"></a>00245 <span class="comment">  buffer becomes empty or the output buffer becomes full. It may introduce some</span>
<a name="l00246"></a>00246 <span class="comment">  output latency (reading input without producing any output) except when</span>
<a name="l00247"></a>00247 <span class="comment">  forced to flush.</span>
<a name="l00248"></a>00248 <span class="comment"></span>
<a name="l00249"></a>00249 <span class="comment">    The detailed semantics are as follows. deflate performs one or both of the</span>
<a name="l00250"></a>00250 <span class="comment">  following actions:</span>
<a name="l00251"></a>00251 <span class="comment"></span>
<a name="l00252"></a>00252 <span class="comment">  - Compress more input starting at next_in and update next_in and avail_in</span>
<a name="l00253"></a>00253 <span class="comment">    accordingly. If not all input can be processed (because there is not</span>
<a name="l00254"></a>00254 <span class="comment">    enough room in the output buffer), next_in and avail_in are updated and</span>
<a name="l00255"></a>00255 <span class="comment">    processing will resume at this point for the next call of deflate().</span>
<a name="l00256"></a>00256 <span class="comment"></span>
<a name="l00257"></a>00257 <span class="comment">  - Provide more output starting at next_out and update next_out and avail_out</span>
<a name="l00258"></a>00258 <span class="comment">    accordingly. This action is forced if the parameter flush is non zero.</span>
<a name="l00259"></a>00259 <span class="comment">    Forcing flush frequently degrades the compression ratio, so this parameter</span>
<a name="l00260"></a>00260 <span class="comment">    should be set only when necessary (in interactive applications).</span>
<a name="l00261"></a>00261 <span class="comment">    Some output may be provided even if flush is not set.</span>
<a name="l00262"></a>00262 <span class="comment"></span>
<a name="l00263"></a>00263 <span class="comment">  Before the call of deflate(), the application should ensure that at least</span>
<a name="l00264"></a>00264 <span class="comment">  one of the actions is possible, by providing more input and/or consuming</span>
<a name="l00265"></a>00265 <span class="comment">  more output, and updating avail_in or avail_out accordingly; avail_out</span>
<a name="l00266"></a>00266 <span class="comment">  should never be zero before the call. The application can consume the</span>
<a name="l00267"></a>00267 <span class="comment">  compressed output when it wants, for example when the output buffer is full</span>
<a name="l00268"></a>00268 <span class="comment">  (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK</span>
<a name="l00269"></a>00269 <span class="comment">  and with zero avail_out, it must be called again after making room in the</span>
<a name="l00270"></a>00270 <span class="comment">  output buffer because there might be more output pending.</span>
<a name="l00271"></a>00271 <span class="comment"></span>
<a name="l00272"></a>00272 <span class="comment">    Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to</span>
<a name="l00273"></a>00273 <span class="comment">  decide how much data to accumualte before producing output, in order to</span>
<a name="l00274"></a>00274 <span class="comment">  maximize compression.</span>
<a name="l00275"></a>00275 <span class="comment"></span>
<a name="l00276"></a>00276 <span class="comment">    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is</span>
<a name="l00277"></a>00277 <span class="comment">  flushed to the output buffer and the output is aligned on a byte boundary, so</span>
<a name="l00278"></a>00278 <span class="comment">  that the decompressor can get all input data available so far. (In particular</span>
<a name="l00279"></a>00279 <span class="comment">  avail_in is zero after the call if enough output space has been provided</span>
<a name="l00280"></a>00280 <span class="comment">  before the call.)  Flushing may degrade compression for some compression</span>
<a name="l00281"></a>00281 <span class="comment">  algorithms and so it should be used only when necessary.</span>
<a name="l00282"></a>00282 <span class="comment"></span>
<a name="l00283"></a>00283 <span class="comment">    If flush is set to Z_FULL_FLUSH, all output is flushed as with</span>
<a name="l00284"></a>00284 <span class="comment">  Z_SYNC_FLUSH, and the compression state is reset so that decompression can</span>
<a name="l00285"></a>00285 <span class="comment">  restart from this point if previous compressed data has been damaged or if</span>
<a name="l00286"></a>00286 <span class="comment">  random access is desired. Using Z_FULL_FLUSH too often can seriously degrade</span>
<a name="l00287"></a>00287 <span class="comment">  compression.</span>
<a name="l00288"></a>00288 <span class="comment"></span>
<a name="l00289"></a>00289 <span class="comment">    If deflate returns with avail_out == 0, this function must be called again</span>
<a name="l00290"></a>00290 <span class="comment">  with the same value of the flush parameter and more output space (updated</span>
<a name="l00291"></a>00291 <span class="comment">  avail_out), until the flush is complete (deflate returns with non-zero</span>
<a name="l00292"></a>00292 <span class="comment">  avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that</span>
<a name="l00293"></a>00293 <span class="comment">  avail_out is greater than six to avoid repeated flush markers due to</span>
<a name="l00294"></a>00294 <span class="comment">  avail_out == 0 on return.</span>
<a name="l00295"></a>00295 <span class="comment"></span>
<a name="l00296"></a>00296 <span class="comment">    If the parameter flush is set to Z_FINISH, pending input is processed,</span>
<a name="l00297"></a>00297 <span class="comment">  pending output is flushed and deflate returns with Z_STREAM_END if there</span>
<a name="l00298"></a>00298 <span class="comment">  was enough output space; if deflate returns with Z_OK, this function must be</span>
<a name="l00299"></a>00299 <span class="comment">  called again with Z_FINISH and more output space (updated avail_out) but no</span>
<a name="l00300"></a>00300 <span class="comment">  more input data, until it returns with Z_STREAM_END or an error. After</span>
<a name="l00301"></a>00301 <span class="comment">  deflate has returned Z_STREAM_END, the only possible operations on the</span>
<a name="l00302"></a>00302 <span class="comment">  stream are deflateReset or deflateEnd.</span>
<a name="l00303"></a>00303 <span class="comment"></span>
<a name="l00304"></a>00304 <span class="comment">    Z_FINISH can be used immediately after deflateInit if all the compression</span>
<a name="l00305"></a>00305 <span class="comment">  is to be done in a single step. In this case, avail_out must be at least</span>
<a name="l00306"></a>00306 <span class="comment">  the value returned by deflateBound (see below). If deflate does not return</span>
<a name="l00307"></a>00307 <span class="comment">  Z_STREAM_END, then it must be called again as described above.</span>
<a name="l00308"></a>00308 <span class="comment"></span>
<a name="l00309"></a>00309 <span class="comment">    deflate() sets strm-&gt;adler to the adler32 checksum of all input read</span>
<a name="l00310"></a>00310 <span class="comment">  so far (that is, total_in bytes).</span>
<a name="l00311"></a>00311 <span class="comment"></span>
<a name="l00312"></a>00312 <span class="comment">    deflate() may update strm-&gt;data_type if it can make a good guess about</span>
<a name="l00313"></a>00313 <span class="comment">  the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered</span>
<a name="l00314"></a>00314 <span class="comment">  binary. This field is only for information purposes and does not affect</span>
<a name="l00315"></a>00315 <span class="comment">  the compression algorithm in any manner.</span>
<a name="l00316"></a>00316 <span class="comment"></span>
<a name="l00317"></a>00317 <span class="comment">    deflate() returns Z_OK if some progress has been made (more input</span>
<a name="l00318"></a>00318 <span class="comment">  processed or more output produced), Z_STREAM_END if all input has been</span>
<a name="l00319"></a>00319 <span class="comment">  consumed and all output has been produced (only when flush is set to</span>
<a name="l00320"></a>00320 <span class="comment">  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example</span>
<a name="l00321"></a>00321 <span class="comment">  if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible</span>
<a name="l00322"></a>00322 <span class="comment">  (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not</span>
<a name="l00323"></a>00323 <span class="comment">  fatal, and deflate() can be called again with more input and more output</span>
<a name="l00324"></a>00324 <span class="comment">  space to continue compressing.</span>
<a name="l00325"></a>00325 <span class="comment">*/</span>
<a name="l00326"></a>00326 
<a name="l00327"></a>00327 
<a name="l00328"></a>00328 ZEXTERN <span class="keywordtype">int</span> ZEXPORT deflateEnd OF((z_streamp strm));
<a name="l00329"></a>00329 <span class="comment">/*</span>
<a name="l00330"></a>00330 <span class="comment">     All dynamically allocated data structures for this stream are freed.</span>
<a name="l00331"></a>00331 <span class="comment">   This function discards any unprocessed input and does not flush any</span>
<a name="l00332"></a>00332 <span class="comment">   pending output.</span>
<a name="l00333"></a>00333 <span class="comment"></span>
<a name="l00334"></a>00334 <span class="comment">     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the</span>
<a name="l00335"></a>00335 <span class="comment">   stream state was inconsistent, Z_DATA_ERROR if the stream was freed</span>
<a name="l00336"></a>00336 <span class="comment">   prematurely (some input or output was discarded). In the error case,</span>
<a name="l00337"></a>00337 <span class="comment">   msg may be set but then points to a static string (which must not be</span>
<a name="l00338"></a>00338 <span class="comment">   deallocated).</span>
<a name="l00339"></a>00339 <span class="comment">*/</span>
<a name="l00340"></a>00340 
<a name="l00341"></a>00341 
<a name="l00342"></a>00342 <span class="comment">/*</span>
<a name="l00343"></a>00343 <span class="comment">ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));</span>
<a name="l00344"></a>00344 <span class="comment"></span>
<a name="l00345"></a>00345 <span class="comment">     Initializes the internal stream state for decompression. The fields</span>
<a name="l00346"></a>00346 <span class="comment">   next_in, avail_in, zalloc, zfree and opaque must be initialized before by</span>
<a name="l00347"></a>00347 <span class="comment">   the caller. If next_in is not Z_NULL and avail_in is large enough (the exact</span>
<a name="l00348"></a>00348 <span class="comment">   value depends on the compression method), inflateInit determines the</span>
<a name="l00349"></a>00349 <span class="comment">   compression method from the zlib header and allocates all data structures</span>
<a name="l00350"></a>00350 <span class="comment">   accordingly; otherwise the allocation will be deferred to the first call of</span>
<a name="l00351"></a>00351 <span class="comment">   inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to</span>
<a name="l00352"></a>00352 <span class="comment">   use default allocation functions.</span>
<a name="l00353"></a>00353 <span class="comment"></span>
<a name="l00354"></a>00354 <span class="comment">     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough</span>
<a name="l00355"></a>00355 <span class="comment">   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the</span>
<a name="l00356"></a>00356 <span class="comment">   version assumed by the caller.  msg is set to null if there is no error</span>
<a name="l00357"></a>00357 <span class="comment">   message. inflateInit does not perform any decompression apart from reading</span>
<a name="l00358"></a>00358 <span class="comment">   the zlib header if present: this will be done by inflate().  (So next_in and</span>
<a name="l00359"></a>00359 <span class="comment">   avail_in may be modified, but next_out and avail_out are unchanged.)</span>
<a name="l00360"></a>00360 <span class="comment">*/</span>
<a name="l00361"></a>00361 
<a name="l00362"></a>00362 
<a name="l00363"></a>00363 ZEXTERN <span class="keywordtype">int</span> ZEXPORT inflate OF((z_streamp strm, <span class="keywordtype">int</span> flush));
<a name="l00364"></a>00364 <span class="comment">/*</span>
<a name="l00365"></a>00365 <span class="comment">    inflate decompresses as much data as possible, and stops when the input</span>
<a name="l00366"></a>00366 <span class="comment">  buffer becomes empty or the output buffer becomes full. It may introduce</span>
<a name="l00367"></a>00367 <span class="comment">  some output latency (reading input without producing any output) except when</span>
<a name="l00368"></a>00368 <span class="comment">  forced to flush.</span>
<a name="l00369"></a>00369 <span class="comment"></span>
<a name="l00370"></a>00370 <span class="comment">  The detailed semantics are as follows. inflate performs one or both of the</span>
<a name="l00371"></a>00371 <span class="comment">  following actions:</span>
<a name="l00372"></a>00372 <span class="comment"></span>
<a name="l00373"></a>00373 <span class="comment">  - Decompress more input starting at next_in and update next_in and avail_in</span>
<a name="l00374"></a>00374 <span class="comment">    accordingly. If not all input can be processed (because there is not</span>
<a name="l00375"></a>00375 <span class="comment">    enough room in the output buffer), next_in is updated and processing</span>
<a name="l00376"></a>00376 <span class="comment">    will resume at this point for the next call of inflate().</span>
<a name="l00377"></a>00377 <span class="comment"></span>
<a name="l00378"></a>00378 <span class="comment">  - Provide more output starting at next_out and update next_out and avail_out</span>
<a name="l00379"></a>00379 <span class="comment">    accordingly.  inflate() provides as much output as possible, until there</span>
<a name="l00380"></a>00380 <span class="comment">    is no more input data or no more space in the output buffer (see below</span>
<a name="l00381"></a>00381 <span class="comment">    about the flush parameter).</span>
<a name="l00382"></a>00382 <span class="comment"></span>
<a name="l00383"></a>00383 <span class="comment">  Before the call of inflate(), the application should ensure that at least</span>
<a name="l00384"></a>00384 <span class="comment">  one of the actions is possible, by providing more input and/or consuming</span>
<a name="l00385"></a>00385 <span class="comment">  more output, and updating the next_* and avail_* values accordingly.</span>
<a name="l00386"></a>00386 <span class="comment">  The application can consume the uncompressed output when it wants, for</span>
<a name="l00387"></a>00387 <span class="comment">  example when the output buffer is full (avail_out == 0), or after each</span>
<a name="l00388"></a>00388 <span class="comment">  call of inflate(). If inflate returns Z_OK and with zero avail_out, it</span>
<a name="l00389"></a>00389 <span class="comment">  must be called again after making room in the output buffer because there</span>
<a name="l00390"></a>00390 <span class="comment">  might be more output pending.</span>
<a name="l00391"></a>00391 <span class="comment"></span>
<a name="l00392"></a>00392 <span class="comment">    The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH,</span>
<a name="l00393"></a>00393 <span class="comment">  Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much</span>
<a name="l00394"></a>00394 <span class="comment">  output as possible to the output buffer. Z_BLOCK requests that inflate() stop</span>
<a name="l00395"></a>00395 <span class="comment">  if and when it gets to the next deflate block boundary. When decoding the</span>
<a name="l00396"></a>00396 <span class="comment">  zlib or gzip format, this will cause inflate() to return immediately after</span>
<a name="l00397"></a>00397 <span class="comment">  the header and before the first block. When doing a raw inflate, inflate()</span>
<a name="l00398"></a>00398 <span class="comment">  will go ahead and process the first block, and will return when it gets to</span>
<a name="l00399"></a>00399 <span class="comment">  the end of that block, or when it runs out of data.</span>
<a name="l00400"></a>00400 <span class="comment"></span>
<a name="l00401"></a>00401 <span class="comment">    The Z_BLOCK option assists in appending to or combining deflate streams.</span>
<a name="l00402"></a>00402 <span class="comment">  Also to assist in this, on return inflate() will set strm-&gt;data_type to the</span>
<a name="l00403"></a>00403 <span class="comment">  number of unused bits in the last byte taken from strm-&gt;next_in, plus 64</span>
<a name="l00404"></a>00404 <span class="comment">  if inflate() is currently decoding the last block in the deflate stream,</span>
<a name="l00405"></a>00405 <span class="comment">  plus 128 if inflate() returned immediately after decoding an end-of-block</span>
<a name="l00406"></a>00406 <span class="comment">  code or decoding the complete header up to just before the first byte of the</span>
<a name="l00407"></a>00407 <span class="comment">  deflate stream. The end-of-block will not be indicated until all of the</span>
<a name="l00408"></a>00408 <span class="comment">  uncompressed data from that block has been written to strm-&gt;next_out.  The</span>
<a name="l00409"></a>00409 <span class="comment">  number of unused bits may in general be greater than seven, except when</span>
<a name="l00410"></a>00410 <span class="comment">  bit 7 of data_type is set, in which case the number of unused bits will be</span>
<a name="l00411"></a>00411 <span class="comment">  less than eight.</span>
<a name="l00412"></a>00412 <span class="comment"></span>
<a name="l00413"></a>00413 <span class="comment">    inflate() should normally be called until it returns Z_STREAM_END or an</span>
<a name="l00414"></a>00414 <span class="comment">  error. However if all decompression is to be performed in a single step</span>
<a name="l00415"></a>00415 <span class="comment">  (a single call of inflate), the parameter flush should be set to</span>
<a name="l00416"></a>00416 <span class="comment">  Z_FINISH. In this case all pending input is processed and all pending</span>
<a name="l00417"></a>00417 <span class="comment">  output is flushed; avail_out must be large enough to hold all the</span>
<a name="l00418"></a>00418 <span class="comment">  uncompressed data. (The size of the uncompressed data may have been saved</span>
<a name="l00419"></a>00419 <span class="comment">  by the compressor for this purpose.) The next operation on this stream must</span>
<a name="l00420"></a>00420 <span class="comment">  be inflateEnd to deallocate the decompression state. The use of Z_FINISH</span>
<a name="l00421"></a>00421 <span class="comment">  is never required, but can be used to inform inflate that a faster approach</span>
<a name="l00422"></a>00422 <span class="comment">  may be used for the single inflate() call.</span>
<a name="l00423"></a>00423 <span class="comment"></span>
<a name="l00424"></a>00424 <span class="comment">     In this implementation, inflate() always flushes as much output as</span>
<a name="l00425"></a>00425 <span class="comment">  possible to the output buffer, and always uses the faster approach on the</span>
<a name="l00426"></a>00426 <span class="comment">  first call. So the only effect of the flush parameter in this implementation</span>
<a name="l00427"></a>00427 <span class="comment">  is on the return value of inflate(), as noted below, or when it returns early</span>
<a name="l00428"></a>00428 <span class="comment">  because Z_BLOCK is used.</span>
<a name="l00429"></a>00429 <span class="comment"></span>
<a name="l00430"></a>00430 <span class="comment">     If a preset dictionary is needed after this call (see inflateSetDictionary</span>
<a name="l00431"></a>00431 <span class="comment">  below), inflate sets strm-&gt;adler to the adler32 checksum of the dictionary</span>
<a name="l00432"></a>00432 <span class="comment">  chosen by the compressor and returns Z_NEED_DICT; otherwise it sets</span>
<a name="l00433"></a>00433 <span class="comment">  strm-&gt;adler to the adler32 checksum of all output produced so far (that is,</span>
<a name="l00434"></a>00434 <span class="comment">  total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described</span>
<a name="l00435"></a>00435 <span class="comment">  below. At the end of the stream, inflate() checks that its computed adler32</span>
<a name="l00436"></a>00436 <span class="comment">  checksum is equal to that saved by the compressor and returns Z_STREAM_END</span>
<a name="l00437"></a>00437 <span class="comment">  only if the checksum is correct.</span>
<a name="l00438"></a>00438 <span class="comment"></span>
<a name="l00439"></a>00439 <span class="comment">    inflate() will decompress and check either zlib-wrapped or gzip-wrapped</span>
<a name="l00440"></a>00440 <span class="comment">  deflate data.  The header type is detected automatically.  Any information</span>
<a name="l00441"></a>00441 <span class="comment">  contained in the gzip header is not retained, so applications that need that</span>
<a name="l00442"></a>00442 <span class="comment">  information should instead use raw inflate, see inflateInit2() below, or</span>
<a name="l00443"></a>00443 <span class="comment">  inflateBack() and perform their own processing of the gzip header and</span>
<a name="l00444"></a>00444 <span class="comment">  trailer.</span>
<a name="l00445"></a>00445 <span class="comment"></span>
<a name="l00446"></a>00446 <span class="comment">    inflate() returns Z_OK if some progress has been made (more input processed</span>
<a name="l00447"></a>00447 <span class="comment">  or more output produced), Z_STREAM_END if the end of the compressed data has</span>
<a name="l00448"></a>00448 <span class="comment">  been reached and all uncompressed output has been produced, Z_NEED_DICT if a</span>
<a name="l00449"></a>00449 <span class="comment">  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was</span>
<a name="l00450"></a>00450 <span class="comment">  corrupted (input stream not conforming to the zlib format or incorrect check</span>
<a name="l00451"></a>00451 <span class="comment">  value), Z_STREAM_ERROR if the stream structure was inconsistent (for example</span>
<a name="l00452"></a>00452 <span class="comment">  if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory,</span>
<a name="l00453"></a>00453 <span class="comment">  Z_BUF_ERROR if no progress is possible or if there was not enough room in the</span>
<a name="l00454"></a>00454 <span class="comment">  output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and</span>
<a name="l00455"></a>00455 <span class="comment">  inflate() can be called again with more input and more output space to</span>
<a name="l00456"></a>00456 <span class="comment">  continue decompressing. If Z_DATA_ERROR is returned, the application may then</span>
<a name="l00457"></a>00457 <span class="comment">  call inflateSync() to look for a good compression block if a partial recovery</span>
<a name="l00458"></a>00458 <span class="comment">  of the data is desired.</span>
<a name="l00459"></a>00459 <span class="comment">*/</span>
<a name="l00460"></a>00460 
<a name="l00461"></a>00461 
<a name="l00462"></a>00462 ZEXTERN <span class="keywordtype">int</span> ZEXPORT inflateEnd OF((z_streamp strm));
<a name="l00463"></a>00463 <span class="comment">/*</span>
<a name="l00464"></a>00464 <span class="comment">     All dynamically allocated data structures for this stream are freed.</span>
<a name="l00465"></a>00465 <span class="comment">   This function discards any unprocessed input and does not flush any</span>
<a name="l00466"></a>00466 <span class="comment">   pending output.</span>
<a name="l00467"></a>00467 <span class="comment"></span>
<a name="l00468"></a>00468 <span class="comment">     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state</span>
<a name="l00469"></a>00469 <span class="comment">   was inconsistent. In the error case, msg may be set but then points to a</span>
<a name="l00470"></a>00470 <span class="comment">   static string (which must not be deallocated).</span>
<a name="l00471"></a>00471 <span class="comment">*/</span>
<a name="l00472"></a>00472 
<a name="l00473"></a>00473                         <span class="comment">/* Advanced functions */</span>
<a name="l00474"></a>00474 
<a name="l00475"></a>00475 <span class="comment">/*</span>
<a name="l00476"></a>00476 <span class="comment">    The following functions are needed only in some special applications.</span>
<a name="l00477"></a>00477 <span class="comment">*/</span>
<a name="l00478"></a>00478 
<a name="l00479"></a>00479 <span class="comment">/*</span>
<a name="l00480"></a>00480 <span class="comment">ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,</span>
<a name="l00481"></a>00481 <span class="comment">                                     int  level,</span>
<a name="l00482"></a>00482 <span class="comment">                                     int  method,</span>
<a name="l00483"></a>00483 <span class="comment">                                     int  windowBits,</span>
<a name="l00484"></a>00484 <span class="comment">                                     int  memLevel,</span>
<a name="l00485"></a>00485 <span class="comment">                                     int  strategy));</span>
<a name="l00486"></a>00486 <span class="comment"></span>
<a name="l00487"></a>00487 <span class="comment">     This is another version of deflateInit with more compression options. The</span>
<a name="l00488"></a>00488 <span class="comment">   fields next_in, zalloc, zfree and opaque must be initialized before by</span>
<a name="l00489"></a>00489 <span class="comment">   the caller.</span>
<a name="l00490"></a>00490 <span class="comment"></span>
<a name="l00491"></a>00491 <span class="comment">     The method parameter is the compression method. It must be Z_DEFLATED in</span>
<a name="l00492"></a>00492 <span class="comment">   this version of the library.</span>
<a name="l00493"></a>00493 <span class="comment"></span>
<a name="l00494"></a>00494 <span class="comment">     The windowBits parameter is the base two logarithm of the window size</span>
<a name="l00495"></a>00495 <span class="comment">   (the size of the history buffer). It should be in the range 8..15 for this</span>
<a name="l00496"></a>00496 <span class="comment">   version of the library. Larger values of this parameter result in better</span>
<a name="l00497"></a>00497 <span class="comment">   compression at the expense of memory usage. The default value is 15 if</span>
<a name="l00498"></a>00498 <span class="comment">   deflateInit is used instead.</span>
<a name="l00499"></a>00499 <span class="comment"></span>
<a name="l00500"></a>00500 <span class="comment">     windowBits can also be -8..-15 for raw deflate. In this case, -windowBits</span>
<a name="l00501"></a>00501 <span class="comment">   determines the window size. deflate() will then generate raw deflate data</span>
<a name="l00502"></a>00502 <span class="comment">   with no zlib header or trailer, and will not compute an adler32 check value.</span>
<a name="l00503"></a>00503 <span class="comment"></span>
<a name="l00504"></a>00504 <span class="comment">     windowBits can also be greater than 15 for optional gzip encoding. Add</span>
<a name="l00505"></a>00505 <span class="comment">   16 to windowBits to write a simple gzip header and trailer around the</span>
<a name="l00506"></a>00506 <span class="comment">   compressed data instead of a zlib wrapper. The gzip header will have no</span>
<a name="l00507"></a>00507 <span class="comment">   file name, no extra data, no comment, no modification time (set to zero),</span>
<a name="l00508"></a>00508 <span class="comment">   no header crc, and the operating system will be set to 255 (unknown).  If a</span>
<a name="l00509"></a>00509 <span class="comment">   gzip stream is being written, strm-&gt;adler is a crc32 instead of an adler32.</span>
<a name="l00510"></a>00510 <span class="comment"></span>
<a name="l00511"></a>00511 <span class="comment">     The memLevel parameter specifies how much memory should be allocated</span>
<a name="l00512"></a>00512 <span class="comment">   for the internal compression state. memLevel=1 uses minimum memory but</span>
<a name="l00513"></a>00513 <span class="comment">   is slow and reduces compression ratio; memLevel=9 uses maximum memory</span>
<a name="l00514"></a>00514 <span class="comment">   for optimal speed. The default value is 8. See zconf.h for total memory</span>
<a name="l00515"></a>00515 <span class="comment">   usage as a function of windowBits and memLevel.</span>
<a name="l00516"></a>00516 <span class="comment"></span>
<a name="l00517"></a>00517 <span class="comment">     The strategy parameter is used to tune the compression algorithm. Use the</span>
<a name="l00518"></a>00518 <span class="comment">   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a</span>
<a name="l00519"></a>00519 <span class="comment">   filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no</span>
<a name="l00520"></a>00520 <span class="comment">   string match), or Z_RLE to limit match distances to one (run-length</span>
<a name="l00521"></a>00521 <span class="comment">   encoding). Filtered data consists mostly of small values with a somewhat</span>
<a name="l00522"></a>00522 <span class="comment">   random distribution. In this case, the compression algorithm is tuned to</span>
<a name="l00523"></a>00523 <span class="comment">   compress them better. The effect of Z_FILTERED is to force more Huffman</span>
<a name="l00524"></a>00524 <span class="comment">   coding and less string matching; it is somewhat intermediate between</span>
<a name="l00525"></a>00525 <span class="comment">   Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as</span>
<a name="l00526"></a>00526 <span class="comment">   Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy</span>
<a name="l00527"></a>00527 <span class="comment">   parameter only affects the compression ratio but not the correctness of the</span>
<a name="l00528"></a>00528 <span class="comment">   compressed output even if it is not set appropriately.  Z_FIXED prevents the</span>
<a name="l00529"></a>00529 <span class="comment">   use of dynamic Huffman codes, allowing for a simpler decoder for special</span>
<a name="l00530"></a>00530 <span class="comment">   applications.</span>
<a name="l00531"></a>00531 <span class="comment"></span>
<a name="l00532"></a>00532 <span class="comment">      deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough</span>
<a name="l00533"></a>00533 <span class="comment">   memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid</span>
<a name="l00534"></a>00534 <span class="comment">   method). msg is set to null if there is no error message.  deflateInit2 does</span>
<a name="l00535"></a>00535 <span class="comment">   not perform any compression: this will be done by deflate().</span>
<a name="l00536"></a>00536 <span class="comment">*/</span>
<a name="l00537"></a>00537 
<a name="l00538"></a>00538 ZEXTERN <span class="keywordtype">int</span> ZEXPORT deflateSetDictionary OF((z_streamp strm,
<a name="l00539"></a>00539                                              <span class="keyword">const</span> Bytef *dictionary,
<a name="l00540"></a>00540                                              uInt  dictLength));
<a name="l00541"></a>00541 <span class="comment">/*</span>
<a name="l00542"></a>00542 <span class="comment">     Initializes the compression dictionary from the given byte sequence</span>
<a name="l00543"></a>00543 <span class="comment">   without producing any compressed output. This function must be called</span>
<a name="l00544"></a>00544 <span class="comment">   immediately after deflateInit, deflateInit2 or deflateReset, before any</span>
<a name="l00545"></a>00545 <span class="comment">   call of deflate. The compressor and decompressor must use exactly the same</span>
<a name="l00546"></a>00546 <span class="comment">   dictionary (see inflateSetDictionary).</span>
<a name="l00547"></a>00547 <span class="comment"></span>
<a name="l00548"></a>00548 <span class="comment">     The dictionary should consist of strings (byte sequences) that are likely</span>
<a name="l00549"></a>00549 <span class="comment">   to be encountered later in the data to be compressed, with the most commonly</span>
<a name="l00550"></a>00550 <span class="comment">   used strings preferably put towards the end of the dictionary. Using a</span>
<a name="l00551"></a>00551 <span class="comment">   dictionary is most useful when the data to be compressed is short and can be</span>
<a name="l00552"></a>00552 <span class="comment">   predicted with good accuracy; the data can then be compressed better than</span>
<a name="l00553"></a>00553 <span class="comment">   with the default empty dictionary.</span>
<a name="l00554"></a>00554 <span class="comment"></span>
<a name="l00555"></a>00555 <span class="comment">     Depending on the size of the compression data structures selected by</span>
<a name="l00556"></a>00556 <span class="comment">   deflateInit or deflateInit2, a part of the dictionary may in effect be</span>
<a name="l00557"></a>00557 <span class="comment">   discarded, for example if the dictionary is larger than the window size in</span>
<a name="l00558"></a>00558 <span class="comment">   deflate or deflate2. Thus the strings most likely to be useful should be</span>
<a name="l00559"></a>00559 <span class="comment">   put at the end of the dictionary, not at the front. In addition, the</span>
<a name="l00560"></a>00560 <span class="comment">   current implementation of deflate will use at most the window size minus</span>
<a name="l00561"></a>00561 <span class="comment">   262 bytes of the provided dictionary.</span>
<a name="l00562"></a>00562 <span class="comment"></span>
<a name="l00563"></a>00563 <span class="comment">     Upon return of this function, strm-&gt;adler is set to the adler32 value</span>
<a name="l00564"></a>00564 <span class="comment">   of the dictionary; the decompressor may later use this value to determine</span>
<a name="l00565"></a>00565 <span class="comment">   which dictionary has been used by the compressor. (The adler32 value</span>
<a name="l00566"></a>00566 <span class="comment">   applies to the whole dictionary even if only a subset of the dictionary is</span>
<a name="l00567"></a>00567 <span class="comment">   actually used by the compressor.) If a raw deflate was requested, then the</span>
<a name="l00568"></a>00568 <span class="comment">   adler32 value is not computed and strm-&gt;adler is not set.</span>
<a name="l00569"></a>00569 <span class="comment"></span>
<a name="l00570"></a>00570 <span class="comment">     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a</span>
<a name="l00571"></a>00571 <span class="comment">   parameter is invalid (such as NULL dictionary) or the stream state is</span>
<a name="l00572"></a>00572 <span class="comment">   inconsistent (for example if deflate has already been called for this stream</span>
<a name="l00573"></a>00573 <span class="comment">   or if the compression method is bsort). deflateSetDictionary does not</span>
<a name="l00574"></a>00574 <span class="comment">   perform any compression: this will be done by deflate().</span>
<a name="l00575"></a>00575 <span class="comment">*/</span>
<a name="l00576"></a>00576 
<a name="l00577"></a>00577 ZEXTERN <span class="keywordtype">int</span> ZEXPORT deflateCopy OF((z_streamp dest,
<a name="l00578"></a>00578                                     z_streamp source));
<a name="l00579"></a>00579 <span class="comment">/*</span>
<a name="l00580"></a>00580 <span class="comment">     Sets the destination stream as a complete copy of the source stream.</span>
<a name="l00581"></a>00581 <span class="comment"></span>
<a name="l00582"></a>00582 <span class="comment">     This function can be useful when several compression strategies will be</span>
<a name="l00583"></a>00583 <span class="comment">   tried, for example when there are several ways of pre-processing the input</span>
<a name="l00584"></a>00584 <span class="comment">   data with a filter. The streams that will be discarded should then be freed</span>
<a name="l00585"></a>00585 <span class="comment">   by calling deflateEnd.  Note that deflateCopy duplicates the internal</span>
<a name="l00586"></a>00586 <span class="comment">   compression state which can be quite large, so this strategy is slow and</span>
<a name="l00587"></a>00587 <span class="comment">   can consume lots of memory.</span>
<a name="l00588"></a>00588 <span class="comment"></span>
<a name="l00589"></a>00589 <span class="comment">     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not</span>
<a name="l00590"></a>00590 <span class="comment">   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent</span>
<a name="l00591"></a>00591 <span class="comment">   (such as zalloc being NULL). msg is left unchanged in both source and</span>
<a name="l00592"></a>00592 <span class="comment">   destination.</span>
<a name="l00593"></a>00593 <span class="comment">*/</span>
<a name="l00594"></a>00594 
<a name="l00595"></a>00595 ZEXTERN <span class="keywordtype">int</span> ZEXPORT deflateReset OF((z_streamp strm));
<a name="l00596"></a>00596 <span class="comment">/*</span>
<a name="l00597"></a>00597 <span class="comment">     This function is equivalent to deflateEnd followed by deflateInit,</span>
<a name="l00598"></a>00598 <span class="comment">   but does not free and reallocate all the internal compression state.</span>
<a name="l00599"></a>00599 <span class="comment">   The stream will keep the same compression level and any other attributes</span>
<a name="l00600"></a>00600 <span class="comment">   that may have been set by deflateInit2.</span>
<a name="l00601"></a>00601 <span class="comment"></span>
<a name="l00602"></a>00602 <span class="comment">      deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source</span>
<a name="l00603"></a>00603 <span class="comment">   stream state was inconsistent (such as zalloc or state being NULL).</span>
<a name="l00604"></a>00604 <span class="comment">*/</span>
<a name="l00605"></a>00605 
<a name="l00606"></a>00606 ZEXTERN <span class="keywordtype">int</span> ZEXPORT deflateParams OF((z_streamp strm,
<a name="l00607"></a>00607                                       <span class="keywordtype">int</span> level,
<a name="l00608"></a>00608                                       <span class="keywordtype">int</span> strategy));
<a name="l00609"></a>00609 <span class="comment">/*</span>
<a name="l00610"></a>00610 <span class="comment">     Dynamically update the compression level and compression strategy.  The</span>
<a name="l00611"></a>00611 <span class="comment">   interpretation of level and strategy is as in deflateInit2.  This can be</span>
<a name="l00612"></a>00612 <span class="comment">   used to switch between compression and straight copy of the input data, or</span>
<a name="l00613"></a>00613 <span class="comment">   to switch to a different kind of input data requiring a different</span>
<a name="l00614"></a>00614 <span class="comment">   strategy. If the compression level is changed, the input available so far</span>
<a name="l00615"></a>00615 <span class="comment">   is compressed with the old level (and may be flushed); the new level will</span>
<a name="l00616"></a>00616 <span class="comment">   take effect only at the next call of deflate().</span>
<a name="l00617"></a>00617 <span class="comment"></span>
<a name="l00618"></a>00618 <span class="comment">     Before the call of deflateParams, the stream state must be set as for</span>
<a name="l00619"></a>00619 <span class="comment">   a call of deflate(), since the currently available input may have to</span>
<a name="l00620"></a>00620 <span class="comment">   be compressed and flushed. In particular, strm-&gt;avail_out must be non-zero.</span>
<a name="l00621"></a>00621 <span class="comment"></span>
<a name="l00622"></a>00622 <span class="comment">     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source</span>
<a name="l00623"></a>00623 <span class="comment">   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR</span>
<a name="l00624"></a>00624 <span class="comment">   if strm-&gt;avail_out was zero.</span>
<a name="l00625"></a>00625 <span class="comment">*/</span>
<a name="l00626"></a>00626 
<a name="l00627"></a>00627 ZEXTERN <span class="keywordtype">int</span> ZEXPORT deflateTune OF((z_streamp strm,
<a name="l00628"></a>00628                                     <span class="keywordtype">int</span> good_length,
<a name="l00629"></a>00629                                     <span class="keywordtype">int</span> max_lazy,
<a name="l00630"></a>00630                                     <span class="keywordtype">int</span> nice_length,
<a name="l00631"></a>00631                                     <span class="keywordtype">int</span> max_chain));
<a name="l00632"></a>00632 <span class="comment">/*</span>
<a name="l00633"></a>00633 <span class="comment">     Fine tune deflate&#39;s internal compression parameters.  This should only be</span>
<a name="l00634"></a>00634 <span class="comment">   used by someone who understands the algorithm used by zlib&#39;s deflate for</span>
<a name="l00635"></a>00635 <span class="comment">   searching for the best matching string, and even then only by the most</span>
<a name="l00636"></a>00636 <span class="comment">   fanatic optimizer trying to squeeze out the last compressed bit for their</span>
<a name="l00637"></a>00637 <span class="comment">   specific input data.  Read the deflate.c source code for the meaning of the</span>
<a name="l00638"></a>00638 <span class="comment">   max_lazy, good_length, nice_length, and max_chain parameters.</span>
<a name="l00639"></a>00639 <span class="comment"></span>
<a name="l00640"></a>00640 <span class="comment">     deflateTune() can be called after deflateInit() or deflateInit2(), and</span>
<a name="l00641"></a>00641 <span class="comment">   returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.</span>
<a name="l00642"></a>00642 <span class="comment"> */</span>
<a name="l00643"></a>00643 
<a name="l00644"></a>00644 ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
<a name="l00645"></a>00645                                        uLong sourceLen));
<a name="l00646"></a>00646 <span class="comment">/*</span>
<a name="l00647"></a>00647 <span class="comment">     deflateBound() returns an upper bound on the compressed size after</span>
<a name="l00648"></a>00648 <span class="comment">   deflation of sourceLen bytes.  It must be called after deflateInit()</span>
<a name="l00649"></a>00649 <span class="comment">   or deflateInit2().  This would be used to allocate an output buffer</span>
<a name="l00650"></a>00650 <span class="comment">   for deflation in a single pass, and so would be called before deflate().</span>
<a name="l00651"></a>00651 <span class="comment">*/</span>
<a name="l00652"></a>00652 
<a name="l00653"></a>00653 ZEXTERN <span class="keywordtype">int</span> ZEXPORT deflatePrime OF((z_streamp strm,
<a name="l00654"></a>00654                                      <span class="keywordtype">int</span> bits,
<a name="l00655"></a>00655                                      <span class="keywordtype">int</span> value));
<a name="l00656"></a>00656 <span class="comment">/*</span>
<a name="l00657"></a>00657 <span class="comment">     deflatePrime() inserts bits in the deflate output stream.  The intent</span>
<a name="l00658"></a>00658 <span class="comment">  is that this function is used to start off the deflate output with the</span>
<a name="l00659"></a>00659 <span class="comment">  bits leftover from a previous deflate stream when appending to it.  As such,</span>
<a name="l00660"></a>00660 <span class="comment">  this function can only be used for raw deflate, and must be used before the</span>
<a name="l00661"></a>00661 <span class="comment">  first deflate() call after a deflateInit2() or deflateReset().  bits must be</span>
<a name="l00662"></a>00662 <span class="comment">  less than or equal to 16, and that many of the least significant bits of</span>
<a name="l00663"></a>00663 <span class="comment">  value will be inserted in the output.</span>
<a name="l00664"></a>00664 <span class="comment"></span>
<a name="l00665"></a>00665 <span class="comment">      deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source</span>
<a name="l00666"></a>00666 <span class="comment">   stream state was inconsistent.</span>
<a name="l00667"></a>00667 <span class="comment">*/</span>
<a name="l00668"></a>00668 
<a name="l00669"></a>00669 ZEXTERN <span class="keywordtype">int</span> ZEXPORT deflateSetHeader OF((z_streamp strm,
<a name="l00670"></a>00670                                          gz_headerp head));
<a name="l00671"></a>00671 <span class="comment">/*</span>
<a name="l00672"></a>00672 <span class="comment">      deflateSetHeader() provides gzip header information for when a gzip</span>
<a name="l00673"></a>00673 <span class="comment">   stream is requested by deflateInit2().  deflateSetHeader() may be called</span>
<a name="l00674"></a>00674 <span class="comment">   after deflateInit2() or deflateReset() and before the first call of</span>
<a name="l00675"></a>00675 <span class="comment">   deflate().  The text, time, os, extra field, name, and comment information</span>
<a name="l00676"></a>00676 <span class="comment">   in the provided gz_header structure are written to the gzip header (xflag is</span>
<a name="l00677"></a>00677 <span class="comment">   ignored -- the extra flags are set according to the compression level).  The</span>
<a name="l00678"></a>00678 <span class="comment">   caller must assure that, if not Z_NULL, name and comment are terminated with</span>
<a name="l00679"></a>00679 <span class="comment">   a zero byte, and that if extra is not Z_NULL, that extra_len bytes are</span>
<a name="l00680"></a>00680 <span class="comment">   available there.  If hcrc is true, a gzip header crc is included.  Note that</span>
<a name="l00681"></a>00681 <span class="comment">   the current versions of the command-line version of gzip (up through version</span>
<a name="l00682"></a>00682 <span class="comment">   1.3.x) do not support header crc&#39;s, and will report that it is a &quot;multi-part</span>
<a name="l00683"></a>00683 <span class="comment">   gzip file&quot; and give up.</span>
<a name="l00684"></a>00684 <span class="comment"></span>
<a name="l00685"></a>00685 <span class="comment">      If deflateSetHeader is not used, the default gzip header has text false,</span>
<a name="l00686"></a>00686 <span class="comment">   the time set to zero, and os set to 255, with no extra, name, or comment</span>
<a name="l00687"></a>00687 <span class="comment">   fields.  The gzip header is returned to the default state by deflateReset().</span>
<a name="l00688"></a>00688 <span class="comment"></span>
<a name="l00689"></a>00689 <span class="comment">      deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source</span>
<a name="l00690"></a>00690 <span class="comment">   stream state was inconsistent.</span>
<a name="l00691"></a>00691 <span class="comment">*/</span>
<a name="l00692"></a>00692 
<a name="l00693"></a>00693 <span class="comment">/*</span>
<a name="l00694"></a>00694 <span class="comment">ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,</span>
<a name="l00695"></a>00695 <span class="comment">                                     int  windowBits));</span>
<a name="l00696"></a>00696 <span class="comment"></span>
<a name="l00697"></a>00697 <span class="comment">     This is another version of inflateInit with an extra parameter. The</span>
<a name="l00698"></a>00698 <span class="comment">   fields next_in, avail_in, zalloc, zfree and opaque must be initialized</span>
<a name="l00699"></a>00699 <span class="comment">   before by the caller.</span>
<a name="l00700"></a>00700 <span class="comment"></span>
<a name="l00701"></a>00701 <span class="comment">     The windowBits parameter is the base two logarithm of the maximum window</span>
<a name="l00702"></a>00702 <span class="comment">   size (the size of the history buffer).  It should be in the range 8..15 for</span>
<a name="l00703"></a>00703 <span class="comment">   this version of the library. The default value is 15 if inflateInit is used</span>
<a name="l00704"></a>00704 <span class="comment">   instead. windowBits must be greater than or equal to the windowBits value</span>
<a name="l00705"></a>00705 <span class="comment">   provided to deflateInit2() while compressing, or it must be equal to 15 if</span>
<a name="l00706"></a>00706 <span class="comment">   deflateInit2() was not used. If a compressed stream with a larger window</span>
<a name="l00707"></a>00707 <span class="comment">   size is given as input, inflate() will return with the error code</span>
<a name="l00708"></a>00708 <span class="comment">   Z_DATA_ERROR instead of trying to allocate a larger window.</span>
<a name="l00709"></a>00709 <span class="comment"></span>
<a name="l00710"></a>00710 <span class="comment">     windowBits can also be -8..-15 for raw inflate. In this case, -windowBits</span>
<a name="l00711"></a>00711 <span class="comment">   determines the window size. inflate() will then process raw deflate data,</span>
<a name="l00712"></a>00712 <span class="comment">   not looking for a zlib or gzip header, not generating a check value, and not</span>
<a name="l00713"></a>00713 <span class="comment">   looking for any check values for comparison at the end of the stream. This</span>
<a name="l00714"></a>00714 <span class="comment">   is for use with other formats that use the deflate compressed data format</span>
<a name="l00715"></a>00715 <span class="comment">   such as zip.  Those formats provide their own check values. If a custom</span>
<a name="l00716"></a>00716 <span class="comment">   format is developed using the raw deflate format for compressed data, it is</span>
<a name="l00717"></a>00717 <span class="comment">   recommended that a check value such as an adler32 or a crc32 be applied to</span>
<a name="l00718"></a>00718 <span class="comment">   the uncompressed data as is done in the zlib, gzip, and zip formats.  For</span>
<a name="l00719"></a>00719 <span class="comment">   most applications, the zlib format should be used as is. Note that comments</span>
<a name="l00720"></a>00720 <span class="comment">   above on the use in deflateInit2() applies to the magnitude of windowBits.</span>
<a name="l00721"></a>00721 <span class="comment"></span>
<a name="l00722"></a>00722 <span class="comment">     windowBits can also be greater than 15 for optional gzip decoding. Add</span>
<a name="l00723"></a>00723 <span class="comment">   32 to windowBits to enable zlib and gzip decoding with automatic header</span>
<a name="l00724"></a>00724 <span class="comment">   detection, or add 16 to decode only the gzip format (the zlib format will</span>
<a name="l00725"></a>00725 <span class="comment">   return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm-&gt;adler is</span>
<a name="l00726"></a>00726 <span class="comment">   a crc32 instead of an adler32.</span>
<a name="l00727"></a>00727 <span class="comment"></span>
<a name="l00728"></a>00728 <span class="comment">     inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough</span>
<a name="l00729"></a>00729 <span class="comment">   memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg</span>
<a name="l00730"></a>00730 <span class="comment">   is set to null if there is no error message.  inflateInit2 does not perform</span>
<a name="l00731"></a>00731 <span class="comment">   any decompression apart from reading the zlib header if present: this will</span>
<a name="l00732"></a>00732 <span class="comment">   be done by inflate(). (So next_in and avail_in may be modified, but next_out</span>
<a name="l00733"></a>00733 <span class="comment">   and avail_out are unchanged.)</span>
<a name="l00734"></a>00734 <span class="comment">*/</span>
<a name="l00735"></a>00735 
<a name="l00736"></a>00736 ZEXTERN <span class="keywordtype">int</span> ZEXPORT inflateSetDictionary OF((z_streamp strm,
<a name="l00737"></a>00737                                              <span class="keyword">const</span> Bytef *dictionary,
<a name="l00738"></a>00738                                              uInt  dictLength));
<a name="l00739"></a>00739 <span class="comment">/*</span>
<a name="l00740"></a>00740 <span class="comment">     Initializes the decompression dictionary from the given uncompressed byte</span>
<a name="l00741"></a>00741 <span class="comment">   sequence. This function must be called immediately after a call of inflate,</span>
<a name="l00742"></a>00742 <span class="comment">   if that call returned Z_NEED_DICT. The dictionary chosen by the compressor</span>
<a name="l00743"></a>00743 <span class="comment">   can be determined from the adler32 value returned by that call of inflate.</span>
<a name="l00744"></a>00744 <span class="comment">   The compressor and decompressor must use exactly the same dictionary (see</span>
<a name="l00745"></a>00745 <span class="comment">   deflateSetDictionary).  For raw inflate, this function can be called</span>
<a name="l00746"></a>00746 <span class="comment">   immediately after inflateInit2() or inflateReset() and before any call of</span>
<a name="l00747"></a>00747 <span class="comment">   inflate() to set the dictionary.  The application must insure that the</span>
<a name="l00748"></a>00748 <span class="comment">   dictionary that was used for compression is provided.</span>
<a name="l00749"></a>00749 <span class="comment"></span>
<a name="l00750"></a>00750 <span class="comment">     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a</span>
<a name="l00751"></a>00751 <span class="comment">   parameter is invalid (such as NULL dictionary) or the stream state is</span>
<a name="l00752"></a>00752 <span class="comment">   inconsistent, Z_DATA_ERROR if the given dictionary doesn&#39;t match the</span>
<a name="l00753"></a>00753 <span class="comment">   expected one (incorrect adler32 value). inflateSetDictionary does not</span>
<a name="l00754"></a>00754 <span class="comment">   perform any decompression: this will be done by subsequent calls of</span>
<a name="l00755"></a>00755 <span class="comment">   inflate().</span>
<a name="l00756"></a>00756 <span class="comment">*/</span>
<a name="l00757"></a>00757 
<a name="l00758"></a>00758 ZEXTERN <span class="keywordtype">int</span> ZEXPORT inflateSync OF((z_streamp strm));
<a name="l00759"></a>00759 <span class="comment">/*</span>
<a name="l00760"></a>00760 <span class="comment">    Skips invalid compressed data until a full flush point (see above the</span>
<a name="l00761"></a>00761 <span class="comment">  description of deflate with Z_FULL_FLUSH) can be found, or until all</span>
<a name="l00762"></a>00762 <span class="comment">  available input is skipped. No output is provided.</span>
<a name="l00763"></a>00763 <span class="comment"></span>
<a name="l00764"></a>00764 <span class="comment">    inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR</span>
<a name="l00765"></a>00765 <span class="comment">  if no more input was provided, Z_DATA_ERROR if no flush point has been found,</span>
<a name="l00766"></a>00766 <span class="comment">  or Z_STREAM_ERROR if the stream structure was inconsistent. In the success</span>
<a name="l00767"></a>00767 <span class="comment">  case, the application may save the current current value of total_in which</span>
<a name="l00768"></a>00768 <span class="comment">  indicates where valid compressed data was found. In the error case, the</span>
<a name="l00769"></a>00769 <span class="comment">  application may repeatedly call inflateSync, providing more input each time,</span>
<a name="l00770"></a>00770 <span class="comment">  until success or end of the input data.</span>
<a name="l00771"></a>00771 <span class="comment">*/</span>
<a name="l00772"></a>00772 
<a name="l00773"></a>00773 ZEXTERN <span class="keywordtype">int</span> ZEXPORT inflateCopy OF((z_streamp dest,
<a name="l00774"></a>00774                                     z_streamp source));
<a name="l00775"></a>00775 <span class="comment">/*</span>
<a name="l00776"></a>00776 <span class="comment">     Sets the destination stream as a complete copy of the source stream.</span>
<a name="l00777"></a>00777 <span class="comment"></span>
<a name="l00778"></a>00778 <span class="comment">     This function can be useful when randomly accessing a large stream.  The</span>
<a name="l00779"></a>00779 <span class="comment">   first pass through the stream can periodically record the inflate state,</span>
<a name="l00780"></a>00780 <span class="comment">   allowing restarting inflate at those points when randomly accessing the</span>
<a name="l00781"></a>00781 <span class="comment">   stream.</span>
<a name="l00782"></a>00782 <span class="comment"></span>
<a name="l00783"></a>00783 <span class="comment">     inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not</span>
<a name="l00784"></a>00784 <span class="comment">   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent</span>
<a name="l00785"></a>00785 <span class="comment">   (such as zalloc being NULL). msg is left unchanged in both source and</span>
<a name="l00786"></a>00786 <span class="comment">   destination.</span>
<a name="l00787"></a>00787 <span class="comment">*/</span>
<a name="l00788"></a>00788 
<a name="l00789"></a>00789 ZEXTERN <span class="keywordtype">int</span> ZEXPORT inflateReset OF((z_streamp strm));
<a name="l00790"></a>00790 <span class="comment">/*</span>
<a name="l00791"></a>00791 <span class="comment">     This function is equivalent to inflateEnd followed by inflateInit,</span>
<a name="l00792"></a>00792 <span class="comment">   but does not free and reallocate all the internal decompression state.</span>
<a name="l00793"></a>00793 <span class="comment">   The stream will keep attributes that may have been set by inflateInit2.</span>
<a name="l00794"></a>00794 <span class="comment"></span>
<a name="l00795"></a>00795 <span class="comment">      inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source</span>
<a name="l00796"></a>00796 <span class="comment">   stream state was inconsistent (such as zalloc or state being NULL).</span>
<a name="l00797"></a>00797 <span class="comment">*/</span>
<a name="l00798"></a>00798 
<a name="l00799"></a>00799 ZEXTERN <span class="keywordtype">int</span> ZEXPORT inflatePrime OF((z_streamp strm,
<a name="l00800"></a>00800                                      <span class="keywordtype">int</span> bits,
<a name="l00801"></a>00801                                      <span class="keywordtype">int</span> value));
<a name="l00802"></a>00802 <span class="comment">/*</span>
<a name="l00803"></a>00803 <span class="comment">     This function inserts bits in the inflate input stream.  The intent is</span>
<a name="l00804"></a>00804 <span class="comment">  that this function is used to start inflating at a bit position in the</span>
<a name="l00805"></a>00805 <span class="comment">  middle of a byte.  The provided bits will be used before any bytes are used</span>
<a name="l00806"></a>00806 <span class="comment">  from next_in.  This function should only be used with raw inflate, and</span>
<a name="l00807"></a>00807 <span class="comment">  should be used before the first inflate() call after inflateInit2() or</span>
<a name="l00808"></a>00808 <span class="comment">  inflateReset().  bits must be less than or equal to 16, and that many of the</span>
<a name="l00809"></a>00809 <span class="comment">  least significant bits of value will be inserted in the input.</span>
<a name="l00810"></a>00810 <span class="comment"></span>
<a name="l00811"></a>00811 <span class="comment">      inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source</span>
<a name="l00812"></a>00812 <span class="comment">   stream state was inconsistent.</span>
<a name="l00813"></a>00813 <span class="comment">*/</span>
<a name="l00814"></a>00814 
<a name="l00815"></a>00815 ZEXTERN <span class="keywordtype">int</span> ZEXPORT inflateGetHeader OF((z_streamp strm,
<a name="l00816"></a>00816                                          gz_headerp head));
<a name="l00817"></a>00817 <span class="comment">/*</span>
<a name="l00818"></a>00818 <span class="comment">      inflateGetHeader() requests that gzip header information be stored in the</span>
<a name="l00819"></a>00819 <span class="comment">   provided gz_header structure.  inflateGetHeader() may be called after</span>
<a name="l00820"></a>00820 <span class="comment">   inflateInit2() or inflateReset(), and before the first call of inflate().</span>
<a name="l00821"></a>00821 <span class="comment">   As inflate() processes the gzip stream, head-&gt;done is zero until the header</span>
<a name="l00822"></a>00822 <span class="comment">   is completed, at which time head-&gt;done is set to one.  If a zlib stream is</span>
<a name="l00823"></a>00823 <span class="comment">   being decoded, then head-&gt;done is set to -1 to indicate that there will be</span>
<a name="l00824"></a>00824 <span class="comment">   no gzip header information forthcoming.  Note that Z_BLOCK can be used to</span>
<a name="l00825"></a>00825 <span class="comment">   force inflate() to return immediately after header processing is complete</span>
<a name="l00826"></a>00826 <span class="comment">   and before any actual data is decompressed.</span>
<a name="l00827"></a>00827 <span class="comment"></span>
<a name="l00828"></a>00828 <span class="comment">      The text, time, xflags, and os fields are filled in with the gzip header</span>
<a name="l00829"></a>00829 <span class="comment">   contents.  hcrc is set to true if there is a header CRC.  (The header CRC</span>
<a name="l00830"></a>00830 <span class="comment">   was valid if done is set to one.)  If extra is not Z_NULL, then extra_max</span>
<a name="l00831"></a>00831 <span class="comment">   contains the maximum number of bytes to write to extra.  Once done is true,</span>
<a name="l00832"></a>00832 <span class="comment">   extra_len contains the actual extra field length, and extra contains the</span>
<a name="l00833"></a>00833 <span class="comment">   extra field, or that field truncated if extra_max is less than extra_len.</span>
<a name="l00834"></a>00834 <span class="comment">   If name is not Z_NULL, then up to name_max characters are written there,</span>
<a name="l00835"></a>00835 <span class="comment">   terminated with a zero unless the length is greater than name_max.  If</span>
<a name="l00836"></a>00836 <span class="comment">   comment is not Z_NULL, then up to comm_max characters are written there,</span>
<a name="l00837"></a>00837 <span class="comment">   terminated with a zero unless the length is greater than comm_max.  When</span>
<a name="l00838"></a>00838 <span class="comment">   any of extra, name, or comment are not Z_NULL and the respective field is</span>
<a name="l00839"></a>00839 <span class="comment">   not present in the header, then that field is set to Z_NULL to signal its</span>
<a name="l00840"></a>00840 <span class="comment">   absence.  This allows the use of deflateSetHeader() with the returned</span>
<a name="l00841"></a>00841 <span class="comment">   structure to duplicate the header.  However if those fields are set to</span>
<a name="l00842"></a>00842 <span class="comment">   allocated memory, then the application will need to save those pointers</span>
<a name="l00843"></a>00843 <span class="comment">   elsewhere so that they can be eventually freed.</span>
<a name="l00844"></a>00844 <span class="comment"></span>
<a name="l00845"></a>00845 <span class="comment">      If inflateGetHeader is not used, then the header information is simply</span>
<a name="l00846"></a>00846 <span class="comment">   discarded.  The header is always checked for validity, including the header</span>
<a name="l00847"></a>00847 <span class="comment">   CRC if present.  inflateReset() will reset the process to discard the header</span>
<a name="l00848"></a>00848 <span class="comment">   information.  The application would need to call inflateGetHeader() again to</span>
<a name="l00849"></a>00849 <span class="comment">   retrieve the header from the next gzip stream.</span>
<a name="l00850"></a>00850 <span class="comment"></span>
<a name="l00851"></a>00851 <span class="comment">      inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source</span>
<a name="l00852"></a>00852 <span class="comment">   stream state was inconsistent.</span>
<a name="l00853"></a>00853 <span class="comment">*/</span>
<a name="l00854"></a>00854 
<a name="l00855"></a>00855 <span class="comment">/*</span>
<a name="l00856"></a>00856 <span class="comment">ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,</span>
<a name="l00857"></a>00857 <span class="comment">                                        unsigned char FAR *window));</span>
<a name="l00858"></a>00858 <span class="comment"></span>
<a name="l00859"></a>00859 <span class="comment">     Initialize the internal stream state for decompression using inflateBack()</span>
<a name="l00860"></a>00860 <span class="comment">   calls.  The fields zalloc, zfree and opaque in strm must be initialized</span>
<a name="l00861"></a>00861 <span class="comment">   before the call.  If zalloc and zfree are Z_NULL, then the default library-</span>
<a name="l00862"></a>00862 <span class="comment">   derived memory allocation routines are used.  windowBits is the base two</span>
<a name="l00863"></a>00863 <span class="comment">   logarithm of the window size, in the range 8..15.  window is a caller</span>
<a name="l00864"></a>00864 <span class="comment">   supplied buffer of that size.  Except for special applications where it is</span>
<a name="l00865"></a>00865 <span class="comment">   assured that deflate was used with small window sizes, windowBits must be 15</span>
<a name="l00866"></a>00866 <span class="comment">   and a 32K byte window must be supplied to be able to decompress general</span>
<a name="l00867"></a>00867 <span class="comment">   deflate streams.</span>
<a name="l00868"></a>00868 <span class="comment"></span>
<a name="l00869"></a>00869 <span class="comment">     See inflateBack() for the usage of these routines.</span>
<a name="l00870"></a>00870 <span class="comment"></span>
<a name="l00871"></a>00871 <span class="comment">     inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of</span>
<a name="l00872"></a>00872 <span class="comment">   the paramaters are invalid, Z_MEM_ERROR if the internal state could not</span>
<a name="l00873"></a>00873 <span class="comment">   be allocated, or Z_VERSION_ERROR if the version of the library does not</span>
<a name="l00874"></a>00874 <span class="comment">   match the version of the header file.</span>
<a name="l00875"></a>00875 <span class="comment">*/</span>
<a name="l00876"></a>00876 
<a name="l00877"></a>00877 <span class="keyword">typedef</span> unsigned (*in_func) OF((<span class="keywordtype">void</span> FAR *, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> FAR * FAR *));
<a name="l00878"></a>00878 typedef <span class="keywordtype">int</span> (*out_func) OF((<span class="keywordtype">void</span> FAR *, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> FAR *, <span class="keywordtype">unsigned</span>));
<a name="l00879"></a>00879 
<a name="l00880"></a>00880 ZEXTERN <span class="keywordtype">int</span> ZEXPORT inflateBack OF((z_streamp strm,
<a name="l00881"></a>00881                                     in_func in, <span class="keywordtype">void</span> FAR *in_desc,
<a name="l00882"></a>00882                                     out_func out, <span class="keywordtype">void</span> FAR *out_desc));
<a name="l00883"></a>00883 <span class="comment">/*</span>
<a name="l00884"></a>00884 <span class="comment">     inflateBack() does a raw inflate with a single call using a call-back</span>
<a name="l00885"></a>00885 <span class="comment">   interface for input and output.  This is more efficient than inflate() for</span>
<a name="l00886"></a>00886 <span class="comment">   file i/o applications in that it avoids copying between the output and the</span>
<a name="l00887"></a>00887 <span class="comment">   sliding window by simply making the window itself the output buffer.  This</span>
<a name="l00888"></a>00888 <span class="comment">   function trusts the application to not change the output buffer passed by</span>
<a name="l00889"></a>00889 <span class="comment">   the output function, at least until inflateBack() returns.</span>
<a name="l00890"></a>00890 <span class="comment"></span>
<a name="l00891"></a>00891 <span class="comment">     inflateBackInit() must be called first to allocate the internal state</span>
<a name="l00892"></a>00892 <span class="comment">   and to initialize the state with the user-provided window buffer.</span>
<a name="l00893"></a>00893 <span class="comment">   inflateBack() may then be used multiple times to inflate a complete, raw</span>
<a name="l00894"></a>00894 <span class="comment">   deflate stream with each call.  inflateBackEnd() is then called to free</span>
<a name="l00895"></a>00895 <span class="comment">   the allocated state.</span>
<a name="l00896"></a>00896 <span class="comment"></span>
<a name="l00897"></a>00897 <span class="comment">     A raw deflate stream is one with no zlib or gzip header or trailer.</span>
<a name="l00898"></a>00898 <span class="comment">   This routine would normally be used in a utility that reads zip or gzip</span>
<a name="l00899"></a>00899 <span class="comment">   files and writes out uncompressed files.  The utility would decode the</span>
<a name="l00900"></a>00900 <span class="comment">   header and process the trailer on its own, hence this routine expects</span>
<a name="l00901"></a>00901 <span class="comment">   only the raw deflate stream to decompress.  This is different from the</span>
<a name="l00902"></a>00902 <span class="comment">   normal behavior of inflate(), which expects either a zlib or gzip header and</span>
<a name="l00903"></a>00903 <span class="comment">   trailer around the deflate stream.</span>
<a name="l00904"></a>00904 <span class="comment"></span>
<a name="l00905"></a>00905 <span class="comment">     inflateBack() uses two subroutines supplied by the caller that are then</span>
<a name="l00906"></a>00906 <span class="comment">   called by inflateBack() for input and output.  inflateBack() calls those</span>
<a name="l00907"></a>00907 <span class="comment">   routines until it reads a complete deflate stream and writes out all of the</span>
<a name="l00908"></a>00908 <span class="comment">   uncompressed data, or until it encounters an error.  The function&#39;s</span>
<a name="l00909"></a>00909 <span class="comment">   parameters and return types are defined above in the in_func and out_func</span>
<a name="l00910"></a>00910 <span class="comment">   typedefs.  inflateBack() will call in(in_desc, &amp;buf) which should return the</span>
<a name="l00911"></a>00911 <span class="comment">   number of bytes of provided input, and a pointer to that input in buf.  If</span>
<a name="l00912"></a>00912 <span class="comment">   there is no input available, in() must return zero--buf is ignored in that</span>
<a name="l00913"></a>00913 <span class="comment">   case--and inflateBack() will return a buffer error.  inflateBack() will call</span>
<a name="l00914"></a>00914 <span class="comment">   out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].  out()</span>
<a name="l00915"></a>00915 <span class="comment">   should return zero on success, or non-zero on failure.  If out() returns</span>
<a name="l00916"></a>00916 <span class="comment">   non-zero, inflateBack() will return with an error.  Neither in() nor out()</span>
<a name="l00917"></a>00917 <span class="comment">   are permitted to change the contents of the window provided to</span>
<a name="l00918"></a>00918 <span class="comment">   inflateBackInit(), which is also the buffer that out() uses to write from.</span>
<a name="l00919"></a>00919 <span class="comment">   The length written by out() will be at most the window size.  Any non-zero</span>
<a name="l00920"></a>00920 <span class="comment">   amount of input may be provided by in().</span>
<a name="l00921"></a>00921 <span class="comment"></span>
<a name="l00922"></a>00922 <span class="comment">     For convenience, inflateBack() can be provided input on the first call by</span>
<a name="l00923"></a>00923 <span class="comment">   setting strm-&gt;next_in and strm-&gt;avail_in.  If that input is exhausted, then</span>
<a name="l00924"></a>00924 <span class="comment">   in() will be called.  Therefore strm-&gt;next_in must be initialized before</span>
<a name="l00925"></a>00925 <span class="comment">   calling inflateBack().  If strm-&gt;next_in is Z_NULL, then in() will be called</span>
<a name="l00926"></a>00926 <span class="comment">   immediately for input.  If strm-&gt;next_in is not Z_NULL, then strm-&gt;avail_in</span>
<a name="l00927"></a>00927 <span class="comment">   must also be initialized, and then if strm-&gt;avail_in is not zero, input will</span>
<a name="l00928"></a>00928 <span class="comment">   initially be taken from strm-&gt;next_in[0 .. strm-&gt;avail_in - 1].</span>
<a name="l00929"></a>00929 <span class="comment"></span>
<a name="l00930"></a>00930 <span class="comment">     The in_desc and out_desc parameters of inflateBack() is passed as the</span>
<a name="l00931"></a>00931 <span class="comment">   first parameter of in() and out() respectively when they are called.  These</span>
<a name="l00932"></a>00932 <span class="comment">   descriptors can be optionally used to pass any information that the caller-</span>
<a name="l00933"></a>00933 <span class="comment">   supplied in() and out() functions need to do their job.</span>
<a name="l00934"></a>00934 <span class="comment"></span>
<a name="l00935"></a>00935 <span class="comment">     On return, inflateBack() will set strm-&gt;next_in and strm-&gt;avail_in to</span>
<a name="l00936"></a>00936 <span class="comment">   pass back any unused input that was provided by the last in() call.  The</span>
<a name="l00937"></a>00937 <span class="comment">   return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR</span>
<a name="l00938"></a>00938 <span class="comment">   if in() or out() returned an error, Z_DATA_ERROR if there was a format</span>
<a name="l00939"></a>00939 <span class="comment">   error in the deflate stream (in which case strm-&gt;msg is set to indicate the</span>
<a name="l00940"></a>00940 <span class="comment">   nature of the error), or Z_STREAM_ERROR if the stream was not properly</span>
<a name="l00941"></a>00941 <span class="comment">   initialized.  In the case of Z_BUF_ERROR, an input or output error can be</span>
<a name="l00942"></a>00942 <span class="comment">   distinguished using strm-&gt;next_in which will be Z_NULL only if in() returned</span>
<a name="l00943"></a>00943 <span class="comment">   an error.  If strm-&gt;next is not Z_NULL, then the Z_BUF_ERROR was due to</span>
<a name="l00944"></a>00944 <span class="comment">   out() returning non-zero.  (in() will always be called before out(), so</span>
<a name="l00945"></a>00945 <span class="comment">   strm-&gt;next_in is assured to be defined if out() returns non-zero.)  Note</span>
<a name="l00946"></a>00946 <span class="comment">   that inflateBack() cannot return Z_OK.</span>
<a name="l00947"></a>00947 <span class="comment">*/</span>
<a name="l00948"></a>00948 
<a name="l00949"></a>00949 ZEXTERN <span class="keywordtype">int</span> ZEXPORT inflateBackEnd OF((z_streamp strm));
<a name="l00950"></a>00950 <span class="comment">/*</span>
<a name="l00951"></a>00951 <span class="comment">     All memory allocated by inflateBackInit() is freed.</span>
<a name="l00952"></a>00952 <span class="comment"></span>
<a name="l00953"></a>00953 <span class="comment">     inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream</span>
<a name="l00954"></a>00954 <span class="comment">   state was inconsistent.</span>
<a name="l00955"></a>00955 <span class="comment">*/</span>
<a name="l00956"></a>00956 
<a name="l00957"></a>00957 ZEXTERN uLong ZEXPORT zlibCompileFlags OF((<span class="keywordtype">void</span>));
<a name="l00958"></a>00958 <span class="comment">/* Return flags indicating compile-time options.</span>
<a name="l00959"></a>00959 <span class="comment"></span>
<a name="l00960"></a>00960 <span class="comment">    Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:</span>
<a name="l00961"></a>00961 <span class="comment">     1.0: size of uInt</span>
<a name="l00962"></a>00962 <span class="comment">     3.2: size of uLong</span>
<a name="l00963"></a>00963 <span class="comment">     5.4: size of voidpf (pointer)</span>
<a name="l00964"></a>00964 <span class="comment">     7.6: size of z_off_t</span>
<a name="l00965"></a>00965 <span class="comment"></span>
<a name="l00966"></a>00966 <span class="comment">    Compiler, assembler, and debug options:</span>
<a name="l00967"></a>00967 <span class="comment">     8: DEBUG</span>
<a name="l00968"></a>00968 <span class="comment">     9: ASMV or ASMINF -- use ASM code</span>
<a name="l00969"></a>00969 <span class="comment">     10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention</span>
<a name="l00970"></a>00970 <span class="comment">     11: 0 (reserved)</span>
<a name="l00971"></a>00971 <span class="comment"></span>
<a name="l00972"></a>00972 <span class="comment">    One-time table building (smaller code, but not thread-safe if true):</span>
<a name="l00973"></a>00973 <span class="comment">     12: BUILDFIXED -- build static block decoding tables when needed</span>
<a name="l00974"></a>00974 <span class="comment">     13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed</span>
<a name="l00975"></a>00975 <span class="comment">     14,15: 0 (reserved)</span>
<a name="l00976"></a>00976 <span class="comment"></span>
<a name="l00977"></a>00977 <span class="comment">    Library content (indicates missing functionality):</span>
<a name="l00978"></a>00978 <span class="comment">     16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking</span>
<a name="l00979"></a>00979 <span class="comment">                          deflate code when not needed)</span>
<a name="l00980"></a>00980 <span class="comment">     17: NO_GZIP -- deflate can&#39;t write gzip streams, and inflate can&#39;t detect</span>
<a name="l00981"></a>00981 <span class="comment">                    and decode gzip streams (to avoid linking crc code)</span>
<a name="l00982"></a>00982 <span class="comment">     18-19: 0 (reserved)</span>
<a name="l00983"></a>00983 <span class="comment"></span>
<a name="l00984"></a>00984 <span class="comment">    Operation variations (changes in library functionality):</span>
<a name="l00985"></a>00985 <span class="comment">     20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate</span>
<a name="l00986"></a>00986 <span class="comment">     21: FASTEST -- deflate algorithm with only one, lowest compression level</span>
<a name="l00987"></a>00987 <span class="comment">     22,23: 0 (reserved)</span>
<a name="l00988"></a>00988 <span class="comment"></span>
<a name="l00989"></a>00989 <span class="comment">    The sprintf variant used by gzprintf (zero is best):</span>
<a name="l00990"></a>00990 <span class="comment">     24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format</span>
<a name="l00991"></a>00991 <span class="comment">     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!</span>
<a name="l00992"></a>00992 <span class="comment">     26: 0 = returns value, 1 = void -- 1 means inferred string length returned</span>
<a name="l00993"></a>00993 <span class="comment"></span>
<a name="l00994"></a>00994 <span class="comment">    Remainder:</span>
<a name="l00995"></a>00995 <span class="comment">     27-31: 0 (reserved)</span>
<a name="l00996"></a>00996 <span class="comment"> */</span>
<a name="l00997"></a>00997 
<a name="l00998"></a>00998 
<a name="l00999"></a>00999                         <span class="comment">/* utility functions */</span>
<a name="l01000"></a>01000 
<a name="l01001"></a>01001 <span class="comment">/*</span>
<a name="l01002"></a>01002 <span class="comment">     The following utility functions are implemented on top of the</span>
<a name="l01003"></a>01003 <span class="comment">   basic stream-oriented functions. To simplify the interface, some</span>
<a name="l01004"></a>01004 <span class="comment">   default options are assumed (compression level and memory usage,</span>
<a name="l01005"></a>01005 <span class="comment">   standard memory allocation functions). The source code of these</span>
<a name="l01006"></a>01006 <span class="comment">   utility functions can easily be modified if you need special options.</span>
<a name="l01007"></a>01007 <span class="comment">*/</span>
<a name="l01008"></a>01008 
<a name="l01009"></a>01009 ZEXTERN <span class="keywordtype">int</span> ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
<a name="l01010"></a>01010                                  const Bytef *source, uLong sourceLen));
<a name="l01011"></a>01011 <span class="comment">/*</span>
<a name="l01012"></a>01012 <span class="comment">     Compresses the source buffer into the destination buffer.  sourceLen is</span>
<a name="l01013"></a>01013 <span class="comment">   the byte length of the source buffer. Upon entry, destLen is the total</span>
<a name="l01014"></a>01014 <span class="comment">   size of the destination buffer, which must be at least the value returned</span>
<a name="l01015"></a>01015 <span class="comment">   by compressBound(sourceLen). Upon exit, destLen is the actual size of the</span>
<a name="l01016"></a>01016 <span class="comment">   compressed buffer.</span>
<a name="l01017"></a>01017 <span class="comment">     This function can be used to compress a whole file at once if the</span>
<a name="l01018"></a>01018 <span class="comment">   input file is mmap&#39;ed.</span>
<a name="l01019"></a>01019 <span class="comment">     compress returns Z_OK if success, Z_MEM_ERROR if there was not</span>
<a name="l01020"></a>01020 <span class="comment">   enough memory, Z_BUF_ERROR if there was not enough room in the output</span>
<a name="l01021"></a>01021 <span class="comment">   buffer.</span>
<a name="l01022"></a>01022 <span class="comment">*/</span>
<a name="l01023"></a>01023 
<a name="l01024"></a>01024 ZEXTERN <span class="keywordtype">int</span> ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
<a name="l01025"></a>01025                                   const Bytef *source, uLong sourceLen,
<a name="l01026"></a>01026                                   <span class="keywordtype">int</span> level));
<a name="l01027"></a>01027 <span class="comment">/*</span>
<a name="l01028"></a>01028 <span class="comment">     Compresses the source buffer into the destination buffer. The level</span>
<a name="l01029"></a>01029 <span class="comment">   parameter has the same meaning as in deflateInit.  sourceLen is the byte</span>
<a name="l01030"></a>01030 <span class="comment">   length of the source buffer. Upon entry, destLen is the total size of the</span>
<a name="l01031"></a>01031 <span class="comment">   destination buffer, which must be at least the value returned by</span>
<a name="l01032"></a>01032 <span class="comment">   compressBound(sourceLen). Upon exit, destLen is the actual size of the</span>
<a name="l01033"></a>01033 <span class="comment">   compressed buffer.</span>
<a name="l01034"></a>01034 <span class="comment"></span>
<a name="l01035"></a>01035 <span class="comment">     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough</span>
<a name="l01036"></a>01036 <span class="comment">   memory, Z_BUF_ERROR if there was not enough room in the output buffer,</span>
<a name="l01037"></a>01037 <span class="comment">   Z_STREAM_ERROR if the level parameter is invalid.</span>
<a name="l01038"></a>01038 <span class="comment">*/</span>
<a name="l01039"></a>01039 
<a name="l01040"></a>01040 ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
<a name="l01041"></a>01041 <span class="comment">/*</span>
<a name="l01042"></a>01042 <span class="comment">     compressBound() returns an upper bound on the compressed size after</span>
<a name="l01043"></a>01043 <span class="comment">   compress() or compress2() on sourceLen bytes.  It would be used before</span>
<a name="l01044"></a>01044 <span class="comment">   a compress() or compress2() call to allocate the destination buffer.</span>
<a name="l01045"></a>01045 <span class="comment">*/</span>
<a name="l01046"></a>01046 
<a name="l01047"></a>01047 ZEXTERN <span class="keywordtype">int</span> ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
<a name="l01048"></a>01048                                    const Bytef *source, uLong sourceLen));
<a name="l01049"></a>01049 <span class="comment">/*</span>
<a name="l01050"></a>01050 <span class="comment">     Decompresses the source buffer into the destination buffer.  sourceLen is</span>
<a name="l01051"></a>01051 <span class="comment">   the byte length of the source buffer. Upon entry, destLen is the total</span>
<a name="l01052"></a>01052 <span class="comment">   size of the destination buffer, which must be large enough to hold the</span>
<a name="l01053"></a>01053 <span class="comment">   entire uncompressed data. (The size of the uncompressed data must have</span>
<a name="l01054"></a>01054 <span class="comment">   been saved previously by the compressor and transmitted to the decompressor</span>
<a name="l01055"></a>01055 <span class="comment">   by some mechanism outside the scope of this compression library.)</span>
<a name="l01056"></a>01056 <span class="comment">   Upon exit, destLen is the actual size of the compressed buffer.</span>
<a name="l01057"></a>01057 <span class="comment">     This function can be used to decompress a whole file at once if the</span>
<a name="l01058"></a>01058 <span class="comment">   input file is mmap&#39;ed.</span>
<a name="l01059"></a>01059 <span class="comment"></span>
<a name="l01060"></a>01060 <span class="comment">     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not</span>
<a name="l01061"></a>01061 <span class="comment">   enough memory, Z_BUF_ERROR if there was not enough room in the output</span>
<a name="l01062"></a>01062 <span class="comment">   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.</span>
<a name="l01063"></a>01063 <span class="comment">*/</span>
<a name="l01064"></a>01064 
<a name="l01065"></a>01065 
<a name="l01066"></a>01066 typedef voidp gzFile;
<a name="l01067"></a>01067 
<a name="l01068"></a>01068 ZEXTERN gzFile ZEXPORT gzopen  OF((const <span class="keywordtype">char</span> *path, const <span class="keywordtype">char</span> *mode));
<a name="l01069"></a>01069 <span class="comment">/*</span>
<a name="l01070"></a>01070 <span class="comment">     Opens a gzip (.gz) file for reading or writing. The mode parameter</span>
<a name="l01071"></a>01071 <span class="comment">   is as in fopen (&quot;rb&quot; or &quot;wb&quot;) but can also include a compression level</span>
<a name="l01072"></a>01072 <span class="comment">   (&quot;wb9&quot;) or a strategy: &#39;f&#39; for filtered data as in &quot;wb6f&quot;, &#39;h&#39; for</span>
<a name="l01073"></a>01073 <span class="comment">   Huffman only compression as in &quot;wb1h&quot;, or &#39;R&#39; for run-length encoding</span>
<a name="l01074"></a>01074 <span class="comment">   as in &quot;wb1R&quot;. (See the description of deflateInit2 for more information</span>
<a name="l01075"></a>01075 <span class="comment">   about the strategy parameter.)</span>
<a name="l01076"></a>01076 <span class="comment"></span>
<a name="l01077"></a>01077 <span class="comment">     gzopen can be used to read a file which is not in gzip format; in this</span>
<a name="l01078"></a>01078 <span class="comment">   case gzread will directly read from the file without decompression.</span>
<a name="l01079"></a>01079 <span class="comment"></span>
<a name="l01080"></a>01080 <span class="comment">     gzopen returns NULL if the file could not be opened or if there was</span>
<a name="l01081"></a>01081 <span class="comment">   insufficient memory to allocate the (de)compression state; errno</span>
<a name="l01082"></a>01082 <span class="comment">   can be checked to distinguish the two cases (if errno is zero, the</span>
<a name="l01083"></a>01083 <span class="comment">   zlib error is Z_MEM_ERROR).  */</span>
<a name="l01084"></a>01084 
<a name="l01085"></a>01085 ZEXTERN gzFile ZEXPORT gzdopen  OF((<span class="keywordtype">int</span> fd, const <span class="keywordtype">char</span> *mode));
<a name="l01086"></a>01086 <span class="comment">/*</span>
<a name="l01087"></a>01087 <span class="comment">     gzdopen() associates a gzFile with the file descriptor fd.  File</span>
<a name="l01088"></a>01088 <span class="comment">   descriptors are obtained from calls like open, dup, creat, pipe or</span>
<a name="l01089"></a>01089 <span class="comment">   fileno (in the file has been previously opened with fopen).</span>
<a name="l01090"></a>01090 <span class="comment">   The mode parameter is as in gzopen.</span>
<a name="l01091"></a>01091 <span class="comment">     The next call of gzclose on the returned gzFile will also close the</span>
<a name="l01092"></a>01092 <span class="comment">   file descriptor fd, just like fclose(fdopen(fd), mode) closes the file</span>
<a name="l01093"></a>01093 <span class="comment">   descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).</span>
<a name="l01094"></a>01094 <span class="comment">     gzdopen returns NULL if there was insufficient memory to allocate</span>
<a name="l01095"></a>01095 <span class="comment">   the (de)compression state.</span>
<a name="l01096"></a>01096 <span class="comment">*/</span>
<a name="l01097"></a>01097 
<a name="l01098"></a>01098 ZEXTERN <span class="keywordtype">int</span> ZEXPORT gzsetparams OF((gzFile file, <span class="keywordtype">int</span> level, <span class="keywordtype">int</span> strategy));
<a name="l01099"></a>01099 <span class="comment">/*</span>
<a name="l01100"></a>01100 <span class="comment">     Dynamically update the compression level or strategy. See the description</span>
<a name="l01101"></a>01101 <span class="comment">   of deflateInit2 for the meaning of these parameters.</span>
<a name="l01102"></a>01102 <span class="comment">     gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not</span>
<a name="l01103"></a>01103 <span class="comment">   opened for writing.</span>
<a name="l01104"></a>01104 <span class="comment">*/</span>
<a name="l01105"></a>01105 
<a name="l01106"></a>01106 ZEXTERN <span class="keywordtype">int</span> ZEXPORT    gzread  OF((gzFile file, voidp buf, <span class="keywordtype">unsigned</span> len));
<a name="l01107"></a>01107 <span class="comment">/*</span>
<a name="l01108"></a>01108 <span class="comment">     Reads the given number of uncompressed bytes from the compressed file.</span>
<a name="l01109"></a>01109 <span class="comment">   If the input file was not in gzip format, gzread copies the given number</span>
<a name="l01110"></a>01110 <span class="comment">   of bytes into the buffer.</span>
<a name="l01111"></a>01111 <span class="comment">     gzread returns the number of uncompressed bytes actually read (0 for</span>
<a name="l01112"></a>01112 <span class="comment">   end of file, -1 for error). */</span>
<a name="l01113"></a>01113 
<a name="l01114"></a>01114 ZEXTERN <span class="keywordtype">int</span> ZEXPORT    gzwrite OF((gzFile file,
<a name="l01115"></a>01115                                    voidpc buf, <span class="keywordtype">unsigned</span> len));
<a name="l01116"></a>01116 <span class="comment">/*</span>
<a name="l01117"></a>01117 <span class="comment">     Writes the given number of uncompressed bytes into the compressed file.</span>
<a name="l01118"></a>01118 <span class="comment">   gzwrite returns the number of uncompressed bytes actually written</span>
<a name="l01119"></a>01119 <span class="comment">   (0 in case of error).</span>
<a name="l01120"></a>01120 <span class="comment">*/</span>
<a name="l01121"></a>01121 
<a name="l01122"></a>01122 ZEXTERN <span class="keywordtype">int</span> ZEXPORTVA   gzprintf OF((gzFile file, const <span class="keywordtype">char</span> *format, ...));
<a name="l01123"></a>01123 <span class="comment">/*</span>
<a name="l01124"></a>01124 <span class="comment">     Converts, formats, and writes the args to the compressed file under</span>
<a name="l01125"></a>01125 <span class="comment">   control of the format string, as in fprintf. gzprintf returns the number of</span>
<a name="l01126"></a>01126 <span class="comment">   uncompressed bytes actually written (0 in case of error).  The number of</span>
<a name="l01127"></a>01127 <span class="comment">   uncompressed bytes written is limited to 4095. The caller should assure that</span>
<a name="l01128"></a>01128 <span class="comment">   this limit is not exceeded. If it is exceeded, then gzprintf() will return</span>
<a name="l01129"></a>01129 <span class="comment">   return an error (0) with nothing written. In this case, there may also be a</span>
<a name="l01130"></a>01130 <span class="comment">   buffer overflow with unpredictable consequences, which is possible only if</span>
<a name="l01131"></a>01131 <span class="comment">   zlib was compiled with the insecure functions sprintf() or vsprintf()</span>
<a name="l01132"></a>01132 <span class="comment">   because the secure snprintf() or vsnprintf() functions were not available.</span>
<a name="l01133"></a>01133 <span class="comment">*/</span>
<a name="l01134"></a>01134 
<a name="l01135"></a>01135 ZEXTERN <span class="keywordtype">int</span> ZEXPORT gzputs OF((gzFile file, const <span class="keywordtype">char</span> *s));
<a name="l01136"></a>01136 <span class="comment">/*</span>
<a name="l01137"></a>01137 <span class="comment">      Writes the given null-terminated string to the compressed file, excluding</span>
<a name="l01138"></a>01138 <span class="comment">   the terminating null character.</span>
<a name="l01139"></a>01139 <span class="comment">      gzputs returns the number of characters written, or -1 in case of error.</span>
<a name="l01140"></a>01140 <span class="comment">*/</span>
<a name="l01141"></a>01141 
<a name="l01142"></a>01142 ZEXTERN <span class="keywordtype">char</span> * ZEXPORT gzgets OF((gzFile file, <span class="keywordtype">char</span> *buf, <span class="keywordtype">int</span> len));
<a name="l01143"></a>01143 <span class="comment">/*</span>
<a name="l01144"></a>01144 <span class="comment">      Reads bytes from the compressed file until len-1 characters are read, or</span>
<a name="l01145"></a>01145 <span class="comment">   a newline character is read and transferred to buf, or an end-of-file</span>
<a name="l01146"></a>01146 <span class="comment">   condition is encountered.  The string is then terminated with a null</span>
<a name="l01147"></a>01147 <span class="comment">   character.</span>
<a name="l01148"></a>01148 <span class="comment">      gzgets returns buf, or Z_NULL in case of error.</span>
<a name="l01149"></a>01149 <span class="comment">*/</span>
<a name="l01150"></a>01150 
<a name="l01151"></a>01151 ZEXTERN <span class="keywordtype">int</span> ZEXPORT    gzputc OF((gzFile file, <span class="keywordtype">int</span> c));
<a name="l01152"></a>01152 <span class="comment">/*</span>
<a name="l01153"></a>01153 <span class="comment">      Writes c, converted to an unsigned char, into the compressed file.</span>
<a name="l01154"></a>01154 <span class="comment">   gzputc returns the value that was written, or -1 in case of error.</span>
<a name="l01155"></a>01155 <span class="comment">*/</span>
<a name="l01156"></a>01156 
<a name="l01157"></a>01157 ZEXTERN <span class="keywordtype">int</span> ZEXPORT    gzgetc OF((gzFile file));
<a name="l01158"></a>01158 <span class="comment">/*</span>
<a name="l01159"></a>01159 <span class="comment">      Reads one byte from the compressed file. gzgetc returns this byte</span>
<a name="l01160"></a>01160 <span class="comment">   or -1 in case of end of file or error.</span>
<a name="l01161"></a>01161 <span class="comment">*/</span>
<a name="l01162"></a>01162 
<a name="l01163"></a>01163 ZEXTERN <span class="keywordtype">int</span> ZEXPORT    gzungetc OF((<span class="keywordtype">int</span> c, gzFile file));
<a name="l01164"></a>01164 <span class="comment">/*</span>
<a name="l01165"></a>01165 <span class="comment">      Push one character back onto the stream to be read again later.</span>
<a name="l01166"></a>01166 <span class="comment">   Only one character of push-back is allowed.  gzungetc() returns the</span>
<a name="l01167"></a>01167 <span class="comment">   character pushed, or -1 on failure.  gzungetc() will fail if a</span>
<a name="l01168"></a>01168 <span class="comment">   character has been pushed but not read yet, or if c is -1. The pushed</span>
<a name="l01169"></a>01169 <span class="comment">   character will be discarded if the stream is repositioned with gzseek()</span>
<a name="l01170"></a>01170 <span class="comment">   or gzrewind().</span>
<a name="l01171"></a>01171 <span class="comment">*/</span>
<a name="l01172"></a>01172 
<a name="l01173"></a>01173 ZEXTERN <span class="keywordtype">int</span> ZEXPORT    gzflush OF((gzFile file, <span class="keywordtype">int</span> flush));
<a name="l01174"></a>01174 <span class="comment">/*</span>
<a name="l01175"></a>01175 <span class="comment">     Flushes all pending output into the compressed file. The parameter</span>
<a name="l01176"></a>01176 <span class="comment">   flush is as in the deflate() function. The return value is the zlib</span>
<a name="l01177"></a>01177 <span class="comment">   error number (see function gzerror below). gzflush returns Z_OK if</span>
<a name="l01178"></a>01178 <span class="comment">   the flush parameter is Z_FINISH and all output could be flushed.</span>
<a name="l01179"></a>01179 <span class="comment">     gzflush should be called only when strictly necessary because it can</span>
<a name="l01180"></a>01180 <span class="comment">   degrade compression.</span>
<a name="l01181"></a>01181 <span class="comment">*/</span>
<a name="l01182"></a>01182 
<a name="l01183"></a>01183 ZEXTERN z_off_t ZEXPORT    gzseek OF((gzFile file,
<a name="l01184"></a>01184                                       z_off_t offset, <span class="keywordtype">int</span> whence));
<a name="l01185"></a>01185 <span class="comment">/*</span>
<a name="l01186"></a>01186 <span class="comment">      Sets the starting position for the next gzread or gzwrite on the</span>
<a name="l01187"></a>01187 <span class="comment">   given compressed file. The offset represents a number of bytes in the</span>
<a name="l01188"></a>01188 <span class="comment">   uncompressed data stream. The whence parameter is defined as in lseek(2);</span>
<a name="l01189"></a>01189 <span class="comment">   the value SEEK_END is not supported.</span>
<a name="l01190"></a>01190 <span class="comment">     If the file is opened for reading, this function is emulated but can be</span>
<a name="l01191"></a>01191 <span class="comment">   extremely slow. If the file is opened for writing, only forward seeks are</span>
<a name="l01192"></a>01192 <span class="comment">   supported; gzseek then compresses a sequence of zeroes up to the new</span>
<a name="l01193"></a>01193 <span class="comment">   starting position.</span>
<a name="l01194"></a>01194 <span class="comment"></span>
<a name="l01195"></a>01195 <span class="comment">      gzseek returns the resulting offset location as measured in bytes from</span>
<a name="l01196"></a>01196 <span class="comment">   the beginning of the uncompressed stream, or -1 in case of error, in</span>
<a name="l01197"></a>01197 <span class="comment">   particular if the file is opened for writing and the new starting position</span>
<a name="l01198"></a>01198 <span class="comment">   would be before the current position.</span>
<a name="l01199"></a>01199 <span class="comment">*/</span>
<a name="l01200"></a>01200 
<a name="l01201"></a>01201 ZEXTERN <span class="keywordtype">int</span> ZEXPORT    gzrewind OF((gzFile file));
<a name="l01202"></a>01202 <span class="comment">/*</span>
<a name="l01203"></a>01203 <span class="comment">     Rewinds the given file. This function is supported only for reading.</span>
<a name="l01204"></a>01204 <span class="comment"></span>
<a name="l01205"></a>01205 <span class="comment">   gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)</span>
<a name="l01206"></a>01206 <span class="comment">*/</span>
<a name="l01207"></a>01207 
<a name="l01208"></a>01208 ZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));
<a name="l01209"></a>01209 <span class="comment">/*</span>
<a name="l01210"></a>01210 <span class="comment">     Returns the starting position for the next gzread or gzwrite on the</span>
<a name="l01211"></a>01211 <span class="comment">   given compressed file. This position represents a number of bytes in the</span>
<a name="l01212"></a>01212 <span class="comment">   uncompressed data stream.</span>
<a name="l01213"></a>01213 <span class="comment"></span>
<a name="l01214"></a>01214 <span class="comment">   gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)</span>
<a name="l01215"></a>01215 <span class="comment">*/</span>
<a name="l01216"></a>01216 
<a name="l01217"></a>01217 ZEXTERN <span class="keywordtype">int</span> ZEXPORT gzeof OF((gzFile file));
<a name="l01218"></a>01218 <span class="comment">/*</span>
<a name="l01219"></a>01219 <span class="comment">     Returns 1 when EOF has previously been detected reading the given</span>
<a name="l01220"></a>01220 <span class="comment">   input stream, otherwise zero.</span>
<a name="l01221"></a>01221 <span class="comment">*/</span>
<a name="l01222"></a>01222 
<a name="l01223"></a>01223 ZEXTERN <span class="keywordtype">int</span> ZEXPORT gzdirect OF((gzFile file));
<a name="l01224"></a>01224 <span class="comment">/*</span>
<a name="l01225"></a>01225 <span class="comment">     Returns 1 if file is being read directly without decompression, otherwise</span>
<a name="l01226"></a>01226 <span class="comment">   zero.</span>
<a name="l01227"></a>01227 <span class="comment">*/</span>
<a name="l01228"></a>01228 
<a name="l01229"></a>01229 ZEXTERN <span class="keywordtype">int</span> ZEXPORT    gzclose OF((gzFile file));
<a name="l01230"></a>01230 <span class="comment">/*</span>
<a name="l01231"></a>01231 <span class="comment">     Flushes all pending output if necessary, closes the compressed file</span>
<a name="l01232"></a>01232 <span class="comment">   and deallocates all the (de)compression state. The return value is the zlib</span>
<a name="l01233"></a>01233 <span class="comment">   error number (see function gzerror below).</span>
<a name="l01234"></a>01234 <span class="comment">*/</span>
<a name="l01235"></a>01235 
<a name="l01236"></a>01236 ZEXTERN const <span class="keywordtype">char</span> * ZEXPORT gzerror OF((gzFile file, <span class="keywordtype">int</span> *errnum));
<a name="l01237"></a>01237 <span class="comment">/*</span>
<a name="l01238"></a>01238 <span class="comment">     Returns the error message for the last error which occurred on the</span>
<a name="l01239"></a>01239 <span class="comment">   given compressed file. errnum is set to zlib error number. If an</span>
<a name="l01240"></a>01240 <span class="comment">   error occurred in the file system and not in the compression library,</span>
<a name="l01241"></a>01241 <span class="comment">   errnum is set to Z_ERRNO and the application may consult errno</span>
<a name="l01242"></a>01242 <span class="comment">   to get the exact error code.</span>
<a name="l01243"></a>01243 <span class="comment">*/</span>
<a name="l01244"></a>01244 
<a name="l01245"></a>01245 ZEXTERN <span class="keywordtype">void</span> ZEXPORT gzclearerr OF((gzFile file));
<a name="l01246"></a>01246 <span class="comment">/*</span>
<a name="l01247"></a>01247 <span class="comment">     Clears the error and end-of-file flags for file. This is analogous to the</span>
<a name="l01248"></a>01248 <span class="comment">   clearerr() function in stdio. This is useful for continuing to read a gzip</span>
<a name="l01249"></a>01249 <span class="comment">   file that is being written concurrently.</span>
<a name="l01250"></a>01250 <span class="comment">*/</span>
<a name="l01251"></a>01251 
<a name="l01252"></a>01252                         <span class="comment">/* checksum functions */</span>
<a name="l01253"></a>01253 
<a name="l01254"></a>01254 <span class="comment">/*</span>
<a name="l01255"></a>01255 <span class="comment">     These functions are not related to compression but are exported</span>
<a name="l01256"></a>01256 <span class="comment">   anyway because they might be useful in applications using the</span>
<a name="l01257"></a>01257 <span class="comment">   compression library.</span>
<a name="l01258"></a>01258 <span class="comment">*/</span>
<a name="l01259"></a>01259 
<a name="l01260"></a>01260 ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
<a name="l01261"></a>01261 <span class="comment">/*</span>
<a name="l01262"></a>01262 <span class="comment">     Update a running Adler-32 checksum with the bytes buf[0..len-1] and</span>
<a name="l01263"></a>01263 <span class="comment">   return the updated checksum. If buf is NULL, this function returns</span>
<a name="l01264"></a>01264 <span class="comment">   the required initial value for the checksum.</span>
<a name="l01265"></a>01265 <span class="comment">   An Adler-32 checksum is almost as reliable as a CRC32 but can be computed</span>
<a name="l01266"></a>01266 <span class="comment">   much faster. Usage example:</span>
<a name="l01267"></a>01267 <span class="comment"></span>
<a name="l01268"></a>01268 <span class="comment">     uLong adler = adler32(0L, Z_NULL, 0);</span>
<a name="l01269"></a>01269 <span class="comment"></span>
<a name="l01270"></a>01270 <span class="comment">     while (read_buffer(buffer, length) != EOF) {</span>
<a name="l01271"></a>01271 <span class="comment">       adler = adler32(adler, buffer, length);</span>
<a name="l01272"></a>01272 <span class="comment">     }</span>
<a name="l01273"></a>01273 <span class="comment">     if (adler != original_adler) error();</span>
<a name="l01274"></a>01274 <span class="comment">*/</span>
<a name="l01275"></a>01275 
<a name="l01276"></a>01276 ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
<a name="l01277"></a>01277                                           z_off_t len2));
<a name="l01278"></a>01278 <span class="comment">/*</span>
<a name="l01279"></a>01279 <span class="comment">     Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1</span>
<a name="l01280"></a>01280 <span class="comment">   and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for</span>
<a name="l01281"></a>01281 <span class="comment">   each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of</span>
<a name="l01282"></a>01282 <span class="comment">   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.</span>
<a name="l01283"></a>01283 <span class="comment">*/</span>
<a name="l01284"></a>01284 
<a name="l01285"></a>01285 ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
<a name="l01286"></a>01286 <span class="comment">/*</span>
<a name="l01287"></a>01287 <span class="comment">     Update a running CRC-32 with the bytes buf[0..len-1] and return the</span>
<a name="l01288"></a>01288 <span class="comment">   updated CRC-32. If buf is NULL, this function returns the required initial</span>
<a name="l01289"></a>01289 <span class="comment">   value for the for the crc. Pre- and post-conditioning (one&#39;s complement) is</span>
<a name="l01290"></a>01290 <span class="comment">   performed within this function so it shouldn&#39;t be done by the application.</span>
<a name="l01291"></a>01291 <span class="comment">   Usage example:</span>
<a name="l01292"></a>01292 <span class="comment"></span>
<a name="l01293"></a>01293 <span class="comment">     uLong crc = crc32(0L, Z_NULL, 0);</span>
<a name="l01294"></a>01294 <span class="comment"></span>
<a name="l01295"></a>01295 <span class="comment">     while (read_buffer(buffer, length) != EOF) {</span>
<a name="l01296"></a>01296 <span class="comment">       crc = crc32(crc, buffer, length);</span>
<a name="l01297"></a>01297 <span class="comment">     }</span>
<a name="l01298"></a>01298 <span class="comment">     if (crc != original_crc) error();</span>
<a name="l01299"></a>01299 <span class="comment">*/</span>
<a name="l01300"></a>01300 
<a name="l01301"></a>01301 ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
<a name="l01302"></a>01302 
<a name="l01303"></a>01303 <span class="comment">/*</span>
<a name="l01304"></a>01304 <span class="comment">     Combine two CRC-32 check values into one.  For two sequences of bytes,</span>
<a name="l01305"></a>01305 <span class="comment">   seq1 and seq2 with lengths len1 and len2, CRC-32 check values were</span>
<a name="l01306"></a>01306 <span class="comment">   calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32</span>
<a name="l01307"></a>01307 <span class="comment">   check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and</span>
<a name="l01308"></a>01308 <span class="comment">   len2.</span>
<a name="l01309"></a>01309 <span class="comment">*/</span>
<a name="l01310"></a>01310 
<a name="l01311"></a>01311 
<a name="l01312"></a>01312                         <span class="comment">/* various hacks, don&#39;t look :) */</span>
<a name="l01313"></a>01313 
<a name="l01314"></a>01314 <span class="comment">/* deflateInit and inflateInit are macros to allow checking the zlib version</span>
<a name="l01315"></a>01315 <span class="comment"> * and the compiler&#39;s view of z_stream:</span>
<a name="l01316"></a>01316 <span class="comment"> */</span>
<a name="l01317"></a>01317 ZEXTERN <span class="keywordtype">int</span> ZEXPORT deflateInit_ OF((z_streamp strm, <span class="keywordtype">int</span> level,
<a name="l01318"></a>01318                                      const <span class="keywordtype">char</span> *version, <span class="keywordtype">int</span> stream_size));
<a name="l01319"></a>01319 ZEXTERN <span class="keywordtype">int</span> ZEXPORT inflateInit_ OF((z_streamp strm,
<a name="l01320"></a>01320                                      const <span class="keywordtype">char</span> *version, <span class="keywordtype">int</span> stream_size));
<a name="l01321"></a>01321 ZEXTERN <span class="keywordtype">int</span> ZEXPORT deflateInit2_ OF((z_streamp strm, <span class="keywordtype">int</span>  level, <span class="keywordtype">int</span>  method,
<a name="l01322"></a>01322                                       <span class="keywordtype">int</span> windowBits, <span class="keywordtype">int</span> memLevel,
<a name="l01323"></a>01323                                       <span class="keywordtype">int</span> strategy, const <span class="keywordtype">char</span> *version,
<a name="l01324"></a>01324                                       <span class="keywordtype">int</span> stream_size));
<a name="l01325"></a>01325 ZEXTERN <span class="keywordtype">int</span> ZEXPORT inflateInit2_ OF((z_streamp strm, <span class="keywordtype">int</span>  windowBits,
<a name="l01326"></a>01326                                       const <span class="keywordtype">char</span> *version, <span class="keywordtype">int</span> stream_size));
<a name="l01327"></a>01327 ZEXTERN <span class="keywordtype">int</span> ZEXPORT inflateBackInit_ OF((z_streamp strm, <span class="keywordtype">int</span> windowBits,
<a name="l01328"></a>01328                                          <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> FAR *window,
<a name="l01329"></a>01329                                          const <span class="keywordtype">char</span> *version,
<a name="l01330"></a>01330                                          <span class="keywordtype">int</span> stream_size));
<a name="l01331"></a>01331 <span class="preprocessor">#define deflateInit(strm, level) \</span>
<a name="l01332"></a>01332 <span class="preprocessor">        deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))</span>
<a name="l01333"></a>01333 <span class="preprocessor"></span><span class="preprocessor">#define inflateInit(strm) \</span>
<a name="l01334"></a>01334 <span class="preprocessor">        inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))</span>
<a name="l01335"></a>01335 <span class="preprocessor"></span><span class="preprocessor">#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \</span>
<a name="l01336"></a>01336 <span class="preprocessor">        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\</span>
<a name="l01337"></a>01337 <span class="preprocessor">                      (strategy),           ZLIB_VERSION, sizeof(z_stream))</span>
<a name="l01338"></a>01338 <span class="preprocessor"></span><span class="preprocessor">#define inflateInit2(strm, windowBits) \</span>
<a name="l01339"></a>01339 <span class="preprocessor">        inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))</span>
<a name="l01340"></a>01340 <span class="preprocessor"></span><span class="preprocessor">#define inflateBackInit(strm, windowBits, window) \</span>
<a name="l01341"></a>01341 <span class="preprocessor">        inflateBackInit_((strm), (windowBits), (window), \</span>
<a name="l01342"></a>01342 <span class="preprocessor">        ZLIB_VERSION, sizeof(z_stream))</span>
<a name="l01343"></a>01343 <span class="preprocessor"></span>
<a name="l01344"></a>01344 
<a name="l01345"></a>01345 <span class="preprocessor">#if !defined(ZUTIL_H) &amp;&amp; !defined(NO_DUMMY_DECL)</span>
<a name="l01346"></a><a class="code" href="structinternal__state.html">01346</a> <span class="preprocessor"></span>    <span class="keyword">struct </span><a class="code" href="structinternal__state.html">internal_state</a> {<span class="keywordtype">int</span> dummy;}; <span class="comment">/* hack for buggy compilers */</span>
<a name="l01347"></a>01347 <span class="preprocessor">#endif</span>
<a name="l01348"></a>01348 <span class="preprocessor"></span>
<a name="l01349"></a>01349 ZEXTERN <span class="keyword">const</span> <span class="keywordtype">char</span>   * ZEXPORT zError           OF((<span class="keywordtype">int</span>));
<a name="l01350"></a>01350 ZEXTERN <span class="keywordtype">int</span>            ZEXPORT inflateSyncPoint OF((z_streamp z));
<a name="l01351"></a>01351 ZEXTERN <span class="keyword">const</span> uLongf * ZEXPORT get_crc_table    OF((<span class="keywordtype">void</span>));
<a name="l01352"></a>01352 
<a name="l01353"></a>01353 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l01354"></a>01354 <span class="preprocessor"></span>}
<a name="l01355"></a>01355 <span class="preprocessor">#endif</span>
<a name="l01356"></a>01356 <span class="preprocessor"></span>
<a name="l01357"></a>01357 <span class="preprocessor">#endif </span><span class="comment">/* ZLIB_H */</span>
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Thu May 24 2012 23:05:02 for pdfToText by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6
</small></address>

</body>
</html>
